Commit 2aedac82 authored by Axel Kingsley's avatar Axel Kingsley Committed by GitHub

Fix Flake in TestDiscovery (#8765)

parent bf7f81a9
...@@ -335,22 +335,25 @@ func TestDiscovery(t *testing.T) { ...@@ -335,22 +335,25 @@ func TestDiscovery(t *testing.T) {
} }
} }
// For each node, check that they have recorded metadata about the other nodes during discovery // Check that among known connections (B-A, B-C), we have metadata
for _, n1 := range []*NodeP2P{nodeA, nodeB, nodeC} { type mdcheck struct {
eps, ok := n1.Host().Peerstore().(store.ExtendedPeerstore) n1 *NodeP2P
n2 *NodeP2P
}
cases := []mdcheck{
{nodeB, nodeA},
{nodeB, nodeC},
}
for _, c := range cases {
// make peerstore metadata available
eps, ok := c.n1.Host().Peerstore().(store.ExtendedPeerstore)
require.True(t, ok) require.True(t, ok)
for _, n2 := range []*NodeP2P{nodeA, nodeB, nodeC} { // confirm n1 has metadata about n2
if n1 == n2 { md, err := eps.GetPeerMetadata(c.n2.Host().ID())
continue require.NoError(t, err)
} require.NotEmpty(t, md.ENR)
md, err := eps.GetPeerMetadata(n2.Host().ID()) require.Equal(t, uint64(901), md.OPStackID)
require.NoError(t, err)
// we don't scrutinize the ENR itself, just that it exists
require.NotEmpty(t, md.ENR)
require.Equal(t, uint64(901), md.OPStackID)
}
} }
} }
// Most tests should use mocknets instead of using the actual local host network // Most tests should use mocknets instead of using the actual local host network
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment