Do not rely on peer order in TestDebugServer_ListPeers (#9988)

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
Radosław Kapka 2021-12-06 20:29:48 +01:00 committed by GitHub
parent c9f5f8dad5
commit e53be1acbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,11 +40,19 @@ func TestDebugServer_ListPeers(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, 2, len(res.Responses))
assert.Equal(t, int(ethpb.PeerDirection_INBOUND), int(res.Responses[0].Direction), "Expected 1st peer to be an inbound")
direction1 := res.Responses[0].Direction
direction2 := res.Responses[1].Direction
assert.Equal(t,
true,
direction1 == ethpb.PeerDirection_INBOUND || direction2 == ethpb.PeerDirection_INBOUND,
"Expected an inbound peer")
assert.Equal(t,
true,
direction1 == ethpb.PeerDirection_OUTBOUND || direction2 == ethpb.PeerDirection_OUTBOUND,
"Expected an outbound peer")
if len(res.Responses[0].ListeningAddresses) == 0 {
t.Errorf("Expected 1st peer to have a multiaddress, instead they have no addresses")
}
assert.Equal(t, ethpb.PeerDirection_OUTBOUND, res.Responses[1].Direction, "Expected 2st peer to be an outbound connection")
if len(res.Responses[1].ListeningAddresses) == 0 {
t.Errorf("Expected 2nd peer to have a multiaddress, instead they have no addresses")
}