itest: fix flake in graph_topology_notifications

We need to make sure to wait for the `ListPeers` to give us the latest
response.
This commit is contained in:
yyforyongyu committed 2025-01-16 16:19:37 +08:00
1 parent 572784a6a1
commit 848f42ea1d
1 file changed
+18 -9
+18 -9
View File
@@ -660,18 +660,27 @@ func testUpdateNodeAnnouncement(ht *lntest.HarnessTest) {
func assertSyncType(ht *lntest.HarnessTest, hn *node.HarnessNode, func assertSyncType(ht *lntest.HarnessTest, hn *node.HarnessNode,
peer string, syncType lnrpc.Peer_SyncType) { peer string, syncType lnrpc.Peer_SyncType) {
resp := hn.RPC.ListPeers() err := wait.NoError(func() error {
for _, rpcPeer := range resp.Peers { resp := hn.RPC.ListPeers()
if rpcPeer.PubKey != peer {
continue for _, rpcPeer := range resp.Peers {
if rpcPeer.PubKey != peer {
continue
}
// Exit early if the sync type is matched.
if syncType == rpcPeer.SyncType {
return nil
}
return fmt.Errorf("sync type: want %v got %v", syncType,
rpcPeer.SyncType)
} }
require.Equal(ht, syncType, rpcPeer.SyncType) return fmt.Errorf("unable to find peer: %s", peer)
}, defaultTimeout)
return require.NoError(ht, err, "%s: timeout checking sync type", hn.Name())
}
ht.Fatalf("unable to find peer: %s", peer)
} }
// compareNodeAnns compares that two node announcements match or returns an // compareNodeAnns compares that two node announcements match or returns an