mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-03 04:37:30 +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:
@ -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) {
|
func bootstrap(t *testing.T, ctx context.Context, dhts []*IpfsDHT) {
|
||||||
var wg sync.WaitGroup
|
|
||||||
for _, dht := range dhts {
|
// try multiple rounds...
|
||||||
wg.Add(1)
|
rounds := 5
|
||||||
go func() {
|
for i := 0; i < rounds; i++ {
|
||||||
defer wg.Done()
|
fmt.Printf("bootstrapping round %d/%d\n", i, rounds)
|
||||||
dht.Bootstrap(ctx)
|
|
||||||
}()
|
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) {
|
func TestPing(t *testing.T) {
|
||||||
@ -264,6 +272,8 @@ func TestBootstrap(t *testing.T) {
|
|||||||
connect(t, ctx, dhts[i], dhts[(i+1)%len(dhts)])
|
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)
|
t.Logf("bootstrapping them so they find each other", nDHTs)
|
||||||
ctxT, _ := context.WithTimeout(ctx, 5*time.Second)
|
ctxT, _ := context.WithTimeout(ctx, 5*time.Second)
|
||||||
bootstrap(t, ctxT, dhts)
|
bootstrap(t, ctxT, dhts)
|
||||||
|
Reference in New Issue
Block a user