Commit 8f45dbfd authored by Steven Allen's avatar Steven Allen

test: connect each peer precisely once.

Otherwise, some tests will get confused by duplicate (temporary, we close
duplicates quickly) connections.

fixes libp2p/go-libp2p#100
parent 9b117d88
...@@ -102,12 +102,10 @@ func connectSwarms(t *testing.T, ctx context.Context, swarms []*Swarm) { ...@@ -102,12 +102,10 @@ func connectSwarms(t *testing.T, ctx context.Context, swarms []*Swarm) {
} }
log.Info("Connecting swarms simultaneously.") log.Info("Connecting swarms simultaneously.")
for _, s1 := range swarms { for i, s1 := range swarms {
for _, s2 := range swarms { for _, s2 := range swarms[i+1:] {
if s2.local != s1.local { // don't connect to self. wg.Add(1)
wg.Add(1) connect(s1, s2.LocalPeer(), s2.ListenAddresses()[0]) // try the first.
connect(s1, s2.LocalPeer(), s2.ListenAddresses()[0]) // try the first.
}
} }
} }
wg.Wait() wg.Wait()
......
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