Skip to content

Commit 184b601

Browse files
committed
fix race in tests
1 parent ab13fd6 commit 184b601

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

p2p/discovery_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ func TestDiscovery(t *testing.T) {
8484
assert.Equal(t, 4, len(comm3.host.Peerstore().Peers()))
8585
assert.Equal(t, 4, len(comm4.host.Peerstore().Peers()))
8686

87+
comm.discovery.mu.Lock()
8788
assert.Equal(t, 3, len(comm.discovery.knownPeers))
8889
for peer, knownPeers := range comm.discovery.knownPeers {
8990
assert.LessOrEqual(t, len(knownPeers.Addrs), 4, "%s has more than 4 addresses (%d)?", peer.String(), len(knownPeers.Addrs))
9091
}
92+
comm.discovery.mu.Unlock()
9193
}

0 commit comments

Comments
 (0)