mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-05 22:33:10 +00:00
Re-enable disabled gossipsub test (#566)
And change it to take into account the fact that libp2p now trims connections immediately (when no grace-period is specified) instead of waiting for a timeout.
This commit is contained in:
parent
dc33a34d4d
commit
19ffbb3a48
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user