package swarm import ( "sync" "testing" "time" peer "github.com/jbenet/go-ipfs/p2p/peer" context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ) func TestSimultOpen(t *testing.T) { // t.Skip("skipping for another test") ctx := context.Background() swarms, peers := makeSwarms(ctx, t, 2) // connect everyone { var wg sync.WaitGroup connect := func(s *Swarm, dst peer.ID, addr ma.Multiaddr) { // copy for other peer s.peers.AddAddress(dst, addr) if _, err := s.Dial(ctx, dst); err != nil { t.Fatal("error swarm dialing to peer", err) } wg.Done() } log.Info("Connecting swarms simultaneously.") wg.Add(2) go connect(swarms[0], swarms[1].local, peers[1].Addr) go connect(swarms[1], swarms[0].local, peers[0].Addr) wg.Wait() } for _, s := range swarms { s.Close() } } func TestSimultOpenMany(t *testing.T) { // t.Skip("very very slow") addrs := 20 SubtestSwarm(t, addrs, 10) } func TestSimultOpenFewStress(t *testing.T) { if testing.Short() { t.SkipNow() } // t.Skip("skipping for another test") msgs := 40 swarms := 2 rounds := 10 // rounds := 100 for i := 0; i < rounds; i++ { SubtestSwarm(t, swarms, msgs) <-time.After(10 * time.Millisecond) } }