Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
fix: call to (*T).Fatal from a non-test goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Apr 6, 2022
1 parent 7b62028 commit 44b17db
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ func TestSimultDials(t *testing.T) {
// connect everyone
{
var wg sync.WaitGroup
errs := make(chan error, 20) // 2 connect calls in each of the 10 for-loop iterations
connect := func(s *Swarm, dst peer.ID, addr ma.Multiaddr) {
// copy for other peer
log.Debugf("TestSimultOpen: connecting: %s --> %s (%s)", s.LocalPeer(), dst, addr)
s.Peerstore().AddAddr(dst, addr, peerstore.TempAddrTTL)
if _, err := s.DialPeer(ctx, dst); err != nil {
t.Fatal("error swarm dialing to peer", err)
errs <- err
}
wg.Done()
}
Expand All @@ -116,6 +117,13 @@ func TestSimultDials(t *testing.T) {
go connect(swarms[1], swarms[0].LocalPeer(), ifaceAddrs0[0])
}
wg.Wait()
close(errs)

for err := range errs {
if err != nil {
t.Fatal("error swarm dialing to peer", err)
}
}
}

// should still just have 1, at most 2 connections :)
Expand Down

0 comments on commit 44b17db

Please sign in to comment.