diff --git a/gossipsub_connmgr_test.go b/gossipsub_connmgr_test.go index accf57dd..a5477026 100644 --- a/gossipsub_connmgr_test.go +++ b/gossipsub_connmgr_test.go @@ -15,7 +15,6 @@ import ( ) func TestGossipsubConnTagMessageDeliveries(t *testing.T) { - t.Skip("Test disabled with go-libp2p v0.22.0") // TODO: reenable test when updating to v0.23.0 ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -90,7 +89,7 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) { // sybil squatters to be connected later sybilHosts := getDefaultHosts(t, nSquatter) for _, h := range sybilHosts { - squatter := &sybilSquatter{h: h} + squatter := &sybilSquatter{h: h, ignoreErrors: true} h.SetStreamHandler(GossipSubID_v10, squatter.handleStream) } @@ -144,18 +143,6 @@ func TestGossipsubConnTagMessageDeliveries(t *testing.T) { allHosts := append(honestHosts, sybilHosts...) connectAll(t, allHosts) - // verify that we have a bunch of connections - for _, h := range honestHosts { - if len(h.Network().Conns()) != nHonest+nSquatter-1 { - t.Errorf("expected to have conns to all peers, have %d", len(h.Network().Conns())) - } - } - - // force the connection managers to trim, so we don't need to muck about with timing as much - for _, cm := range connmgrs { - cm.TrimOpenConns(ctx) - } - // we should still have conns to all the honest peers, but not the sybils for _, h := range honestHosts { nHonestConns := 0 diff --git a/gossipsub_test.go b/gossipsub_test.go index 8c2a216e..4481be9e 100644 --- a/gossipsub_test.go +++ b/gossipsub_test.go @@ -2025,7 +2025,8 @@ func TestGossipSubJoinTopic(t *testing.T) { } type sybilSquatter struct { - h host.Host + h host.Host + ignoreErrors bool // set to false to ignore connection/stream errors. } func (sq *sybilSquatter) handleStream(s network.Stream) { @@ -2033,7 +2034,10 @@ func (sq *sybilSquatter) handleStream(s network.Stream) { os, err := sq.h.NewStream(context.Background(), s.Conn().RemotePeer(), GossipSubID_v10) if err != nil { - panic(err) + if !sq.ignoreErrors { + panic(err) + } + return } // send a subscription for test in the output stream to become candidate for GRAFT @@ -2044,7 +2048,10 @@ func (sq *sybilSquatter) handleStream(s network.Stream) { topic := "test" err = w.WriteMsg(&pb.RPC{Subscriptions: []*pb.RPC_SubOpts{{Subscribe: &truth, Topicid: &topic}}}) if err != nil { - panic(err) + if !sq.ignoreErrors { + panic(err) + } + return } var rpc pb.RPC