Skip to content

Commit 848f42e

Browse files
committed
itest: fix flake in graph_topology_notifications
We need to make sure to wait for the `ListPeers` to give us the latest response.
1 parent 572784a commit 848f42e

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

itest/lnd_channel_graph_test.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -660,18 +660,27 @@ func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
660660
func assertSyncType(ht *lntest.HarnessTest, hn *node.HarnessNode,
661661
peer string, syncType lnrpc.Peer_SyncType) {
662662

663-
resp := hn.RPC.ListPeers()
664-
for _, rpcPeer := range resp.Peers {
665-
if rpcPeer.PubKey != peer {
666-
continue
667-
}
663+
err := wait.NoError(func() error {
664+
resp := hn.RPC.ListPeers()
668665

669-
require.Equal(ht, syncType, rpcPeer.SyncType)
666+
for _, rpcPeer := range resp.Peers {
667+
if rpcPeer.PubKey != peer {
668+
continue
669+
}
670670

671-
return
672-
}
671+
// Exit early if the sync type is matched.
672+
if syncType == rpcPeer.SyncType {
673+
return nil
674+
}
675+
676+
return fmt.Errorf("sync type: want %v got %v", syncType,
677+
rpcPeer.SyncType)
678+
}
679+
680+
return fmt.Errorf("unable to find peer: %s", peer)
681+
}, defaultTimeout)
673682

674-
ht.Fatalf("unable to find peer: %s", peer)
683+
require.NoError(ht, err, "%s: timeout checking sync type", hn.Name())
675684
}
676685

677686
// compareNodeAnns compares that two node announcements match or returns an

0 commit comments

Comments
 (0)