Commit a547c8ee authored by Christian Couder's avatar Christian Couder

exchange/bitswap/bitswap_test: fix t.Fatal in a goroutine

License: MIT
Signed-off-by: default avatarChristian Couder <chriscool@tuxfamily.org>
parent 34cb3acf
......@@ -168,19 +168,31 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
t.Log("Distribute!")
wg := sync.WaitGroup{}
errs := make(chan error)
for _, inst := range instances[1:] {
wg.Add(1)
go func(inst Instance) {
defer wg.Done()
outch, err := inst.Exchange.GetBlocks(ctx, blkeys)
if err != nil {
t.Fatal(err)
errs <- err
}
for _ = range outch {
}
}(inst)
}
wg.Wait()
go func() {
wg.Wait()
close(errs)
}()
for err := range errs {
if err != nil {
t.Fatal(err)
}
}
t.Log("Verify!")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment