dht bootstrap test: rounds. do nothing
odd behavior: only one dht (the last one) is seeing changes to its routing table.
Juan Batiz-Benet committed
Dec 23, 2014 at 19:21 UTC
ef0c25f463715efd90848f71131786821609b958
1 file changed
+18
-8
routing/dht/dht_test.go
+18
-8
@@ -92,15 +92,23 @@ func connect(t *testing.T, ctx context.Context, a, b *IpfsDHT) {
92
}
93
94
func bootstrap(t *testing.T, ctx context.Context, dhts []*IpfsDHT) {
95
- var wg sync.WaitGroup
96
- for _, dht := range dhts {
97
- wg.Add(1)
98
- go func() {
99
- defer wg.Done()
100
- dht.Bootstrap(ctx)
101
- }()
95
+
96
+ // try multiple rounds...
97
+ rounds := 5
98
+ for i := 0; i < rounds; i++ {
99
+ fmt.Printf("bootstrapping round %d/%d\n", i, rounds)
100
+
101
+ var wg sync.WaitGroup
102
+ for _, dht := range dhts {
103
+ wg.Add(1)
104
+ go func() {
105
+ defer wg.Done()
106
+ dht.Bootstrap(ctx)
107
+ }()
108
+ }
109
+ wg.Wait()
110
+
111
}
103
- wg.Wait()
112
}
113
114
func TestPing(t *testing.T) {
@@ -264,6 +272,8 @@ func TestBootstrap(t *testing.T) {
272
connect(t, ctx, dhts[i], dhts[(i+1)%len(dhts)])
273
}
274
275
+ <-time.After(100 * time.Millisecond)
276
+
277
t.Logf("bootstrapping them so they find each other", nDHTs)
278
ctxT, _ := context.WithTimeout(ctx, 5*time.Second)
279
bootstrap(t, ctxT, dhts)