Skip to content

Commit

Permalink
close all connections in the TestFastDisconnect test
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Sep 24, 2021
1 parent 6eada78 commit 7fa07a4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions p2p/protocol/identify/id_glass_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ func TestFastDisconnect(t *testing.T) {
}

// Kill the connection, and make sure we're completely disconnected.
s.Conn().Close()
assert.Eventually(t,
func() bool { return target.Network().Connectedness(s.Conn().RemotePeer()) != network.Connected },
func() bool {
for _, conn := range target.Network().ConnsToPeer(s.Conn().RemotePeer()) {
conn.Close()
}
return target.Network().Connectedness(s.Conn().RemotePeer()) != network.Connected
},
2*time.Second,
time.Millisecond,
)
Expand All @@ -60,7 +64,7 @@ func TestFastDisconnect(t *testing.T) {
defer source.Close()

// only connect to the first address, to make sure we only end up with one connection
require.NoError(t, source.Connect(ctx, peer.AddrInfo{ID: target.ID(), Addrs: target.Addrs()[:1]}))
require.NoError(t, source.Connect(ctx, peer.AddrInfo{ID: target.ID(), Addrs: target.Addrs()}))
s, err := source.NewStream(ctx, target.ID(), ID)
require.NoError(t, err)
select {
Expand Down

0 comments on commit 7fa07a4

Please sign in to comment.