From ef0c25f463715efd90848f71131786821609b958 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 23 Dec 2014 19:21:35 -0800 Subject: [PATCH] dht bootstrap test: rounds. do nothing odd behavior: only one dht (the last one) is seeing changes to its routing table. --- routing/dht/dht_test.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/routing/dht/dht_test.go b/routing/dht/dht_test.go index f2ff099df..3c3ce9954 100644 --- a/routing/dht/dht_test.go +++ b/routing/dht/dht_test.go @@ -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)