Skip to content

Commit

Permalink
Fix another typo and added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeless committed Oct 25, 2023
1 parent d5a2a9c commit 6a42127
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tui/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,9 @@ func printUndo(lastGoodClock *pbsubstreams.BlockRef, cursor string) {
fmt.Printf("\nNext cursor: %s\n", cursor)
}
func printUndoJSON(lastGoodClock *pbsubstreams.BlockRef, cursor string) {
fmt.Printf("{\"undo_until\":{\"num\":%d,\"id\":%s\",\"next_cursor\":\"%s\"}}\n", lastGoodClock.Number, lastGoodClock.Id, cursor)
fmt.Printf(formatUndoJSON(lastGoodClock, cursor) + "\n")
}

func formatUndoJSON(lastGoodClock *pbsubstreams.BlockRef, cursor string) string {
return fmt.Sprintf("{\"undo_until\":{\"num\":%d,\"id\":\"%s\",\"next_cursor\":\"%s\"}}", lastGoodClock.Number, lastGoodClock.Id, cursor)
}
17 changes: 17 additions & 0 deletions tui/print_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package tui

import (
pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
"github.com/stretchr/testify/assert"
"testing"
)

func Test_printUndoJSON(t *testing.T) {
assert.Equal(t,
`{"undo_until":{"num":1,"id":"1","next_cursor":"aa"}}`,
formatUndoJSON(&pbsubstreams.BlockRef{
Id: "1",
Number: 1,
}, "aa"),
)
}

0 comments on commit 6a42127

Please sign in to comment.