diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index 1358903a9..2e63e438e 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -78,6 +78,16 @@ func connect(t *testing.T, ctx context.Context, a, b *IpfsDHT) { if err := a.host.Connect(ctx, pi); err != nil { t.Fatal(err) } + + // loop until connection notification has been received. + // under high load, this may not happen as immediately as we would like. + for a.routingTable.Find(b.self) == "" { + time.Sleep(time.Millisecond * 5) + } + + for b.routingTable.Find(a.self) == "" { + time.Sleep(time.Millisecond * 5) + } } func bootstrap(t *testing.T, ctx context.Context, dhts []*IpfsDHT) {