Skip to content

Commit

Permalink
test(SPV-1095): fix after main rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
dzolt-4chain committed Oct 10, 2024
1 parent 1f8c28c commit 6578b27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 7 additions & 2 deletions examples/sync_merkleroots/sync_merkleroots.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ func main() {

server := "http://localhost:3003/api/v1"

client := walletclient.NewWithXPriv(server, examples.ExampleXPriv)
client, err := walletclient.NewWithXPriv(server, examples.ExampleXPriv)
if err != nil {
fmt.Println("Error: ", err)
examples.GetFullErrorMessage(err)
os.Exit(1)
}
ctx := context.Background()

fmt.Printf("\n\n Initial State Length: \n %d\n\n", len(repository.MerkleRoots))
fmt.Printf("\n\nInitial State Last 5 MerkleRoots (or fewer):\n%+v\n", getLastFiveOrFewer(repository.MerkleRoots))

err := client.SyncMerkleRoots(ctx, repository, 1000*time.Millisecond)
err = client.SyncMerkleRoots(ctx, repository, 1000*time.Millisecond)
if err != nil {
fmt.Println("Error: ", err)
examples.GetFullErrorMessage(err)
Expand Down
20 changes: 12 additions & 8 deletions sync_merkleroots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ func TestSyncMerkleRoots(t *testing.T) {

// given
repo := fixtures.CreateRepository([]models.MerkleRoot{})
client := NewWithXPriv(server.URL, fixtures.XPrivString)
client, err := NewWithXPriv(server.URL, fixtures.XPrivString)
require.NotNil(t, client.xPriv)
require.NoError(t, err)

// when
err := client.SyncMerkleRoots(context.Background(), repo, 0)
err = client.SyncMerkleRoots(context.Background(), repo, 0)

// then
require.NoError(t, err)
Expand Down Expand Up @@ -51,11 +52,12 @@ func TestSyncMerkleRoots(t *testing.T) {
BlockHeight: 2,
},
})
client := NewWithXPriv(server.URL, fixtures.XPrivString)
client, err := NewWithXPriv(server.URL, fixtures.XPrivString)
require.NotNil(t, client.xPriv)
require.NoError(t, err)

// when
err := client.SyncMerkleRoots(context.Background(), repo, 0)
err = client.SyncMerkleRoots(context.Background(), repo, 0)

// then
require.NoError(t, err)
Expand All @@ -71,11 +73,12 @@ func TestSyncMerkleRoots(t *testing.T) {

// given
repo := fixtures.CreateRepository([]models.MerkleRoot{})
client := NewWithXPriv(server.URL, fixtures.XPrivString)
client, err := NewWithXPriv(server.URL, fixtures.XPrivString)
require.NotNil(t, client.xPriv)
require.NoError(t, err)

// when
err := client.SyncMerkleRoots(context.Background(), repo, 10)
err = client.SyncMerkleRoots(context.Background(), repo, 10)

// then
require.ErrorIs(t, err, ErrSyncMerkleRootsTimeout)
Expand All @@ -88,11 +91,12 @@ func TestSyncMerkleRoots(t *testing.T) {

// given
repo := fixtures.CreateRepository([]models.MerkleRoot{})
client := NewWithXPriv(server.URL, fixtures.XPrivString)
client, err := NewWithXPriv(server.URL, fixtures.XPrivString)
require.NotNil(t, client.xPriv)
require.NoError(t, err)

// when
err := client.SyncMerkleRoots(context.Background(), repo, 0)
err = client.SyncMerkleRoots(context.Background(), repo, 0)

// then
require.ErrorIs(t, err, ErrStaleLastEvaluatedKey)
Expand Down

0 comments on commit 6578b27

Please sign in to comment.