diff --git a/pkg/core/statesync_test.go b/pkg/core/statesync_test.go index 9f7ac6bd4..c701c6700 100644 --- a/pkg/core/statesync_test.go +++ b/pkg/core/statesync_test.go @@ -220,16 +220,24 @@ func TestStateSyncModule_Init(t *testing.T) { require.Equal(t, uint32(stateSyncPoint), module.BlockHeight()) // add the rest of MPT nodes and jump to state + alreadyRequested := make(map[util.Uint256]struct{}) for { unknownHashes := module.GetUnknownMPTNodesBatch(1) // restore nodes one-by-one if len(unknownHashes) == 0 { break } + if _, ok := alreadyRequested[unknownHashes[0]]; ok { + t.Fatal("bug: node was requested twice") + } + alreadyRequested[unknownHashes[0]] = struct{}{} + var callbackCalled bool err := bcSpout.GetStateSyncModule().Traverse(unknownHashes[0], func(node mpt.Node, nodeBytes []byte) bool { require.NoError(t, module.AddMPTNodes([][]byte{slice.Copy(nodeBytes)})) + callbackCalled = true return true // add nodes one-by-one }) require.NoError(t, err) + require.True(t, callbackCalled) } // check that module is inactive and statejump is completed