Skip to content

Commit

Permalink
swarm: fix flaky and racy TestDialExistingConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 15, 2022
1 parent 1d64bc1 commit 98060d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion p2p/net/swarm/dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,11 @@ func TestDialExistingConnection(t *testing.T) {
c2, err := s1.DialPeer(context.Background(), s2.LocalPeer())
require.NoError(t, err)

require.Equal(t, c1, c2, "expecting the same connection from both dials")
// There's no good way to assert that this is actually the exact same connection,
// but we can compare a few things to be reasonably sure.
require.Equal(t, c1.LocalMultiaddr(), c2.LocalMultiaddr())
require.Equal(t, c1.RemoteMultiaddr(), c2.RemoteMultiaddr())
require.Equal(t, c1.ID(), c2.ID())
}

func newSilentListener(t *testing.T) ([]ma.Multiaddr, net.Listener) {
Expand Down

0 comments on commit 98060d1

Please sign in to comment.