1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 01:52:26 +08:00

dht bootstrap test: rounds. do nothing

odd behavior: only one dht (the last one) is seeing
changes to its routing table.
This commit is contained in:
Juan Batiz-Benet
2014-12-23 19:21:35 -08:00
parent ccf6f79aa0
commit ef0c25f463

View File

@ -92,15 +92,23 @@ func connect(t *testing.T, ctx context.Context, a, b *IpfsDHT) {
}
func bootstrap(t *testing.T, ctx context.Context, dhts []*IpfsDHT) {
var wg sync.WaitGroup
for _, dht := range dhts {
wg.Add(1)
go func() {
defer wg.Done()
dht.Bootstrap(ctx)
}()
// try multiple rounds...
rounds := 5
for i := 0; i < rounds; i++ {
fmt.Printf("bootstrapping round %d/%d\n", i, rounds)
var wg sync.WaitGroup
for _, dht := range dhts {
wg.Add(1)
go func() {
defer wg.Done()
dht.Bootstrap(ctx)
}()
}
wg.Wait()
}
wg.Wait()
}
func TestPing(t *testing.T) {
@ -264,6 +272,8 @@ func TestBootstrap(t *testing.T) {
connect(t, ctx, dhts[i], dhts[(i+1)%len(dhts)])
}
<-time.After(100 * time.Millisecond)
t.Logf("bootstrapping them so they find each other", nDHTs)
ctxT, _ := context.WithTimeout(ctx, 5*time.Second)
bootstrap(t, ctxT, dhts)