Skip to content

Commit 3768ad0

Browse files
committed
itest: fix flake with universe sync
Fixes #807. If we're syncing a node to a universe that is still in the process of getting proofs pushed to, we sometimes receive leaves with a root that doesn't match the root we fetched at the beginning of the sync process. We should re-try the sync, which we'll do in a separate PR. For now we just want to fix the flake, which we can do by waiting to start a new node until the existing one has finished syncing.
1 parent 107caad commit 3768ad0

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

itest/assertions.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,34 @@ func AssertUniverseRootEquality(t *testing.T,
11981198
))
11991199
}
12001200

1201+
// AssertUniverseRootEqualityEventually checks that the universe roots returned
1202+
// by two daemons are either equal eventually.
1203+
func AssertUniverseRootEqualityEventually(t *testing.T,
1204+
clientA, clientB unirpc.UniverseClient) {
1205+
1206+
ctxb := context.Background()
1207+
ctxt, cancel := context.WithTimeout(ctxb, defaultWaitTimeout)
1208+
defer cancel()
1209+
1210+
err := wait.NoError(func() error {
1211+
rootRequest := &unirpc.AssetRootRequest{}
1212+
universeRootsAlice, err := clientA.AssetRoots(ctxt, rootRequest)
1213+
require.NoError(t, err)
1214+
universeRootsBob, err := clientB.AssetRoots(ctxt, rootRequest)
1215+
require.NoError(t, err)
1216+
1217+
if !AssertUniverseRootsEqual(
1218+
universeRootsAlice, universeRootsBob,
1219+
) {
1220+
1221+
return fmt.Errorf("roots not equal")
1222+
}
1223+
1224+
return nil
1225+
}, defaultWaitTimeout)
1226+
require.NoError(t, err)
1227+
}
1228+
12011229
// AssertUniverseRoot makes sure the given universe root exists with the given
12021230
// sum, either identified by the asset ID or group key.
12031231
func AssertUniverseRoot(t *testing.T, client unirpc.UniverseClient,

itest/multi_asset_group_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ func testMultiAssetGroupSend(t *harnessTest) {
317317
collectibleGroupMembers + 1,
318318
})
319319

320+
AssertUniverseRootEqualityEventually(
321+
t.t, t.tapd, t.universeServer.service,
322+
)
323+
320324
// We'll make a second node now that'll be the receiver of all the
321325
// assets made above.
322326
secondTapd := setupTapdHarness(
@@ -326,6 +330,10 @@ func testMultiAssetGroupSend(t *harnessTest) {
326330
require.NoError(t.t, secondTapd.stop(!*noDelete))
327331
}()
328332

333+
AssertUniverseRootEqualityEventually(
334+
t.t, secondTapd, t.universeServer.service,
335+
)
336+
329337
// Send 5 of the assets to Bob, and verify that they are received.
330338
numUnits := issuableAsset.Asset.Amount
331339
assetType := issuableAsset.Asset.AssetType

0 commit comments

Comments
 (0)