Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
amirylm committed Jul 5, 2024
1 parent 225186d commit 73506d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 68 deletions.
65 changes: 19 additions & 46 deletions core/gossipsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,6 @@ import (
"github.com/stretchr/testify/require"
)

var (
traceEmptySkipList = []string{}
traceMsgEventSkipList = []string{
"ADD_PEER",
"REMOVE_PEER",
"JOIN",
"LEAVE",
"GRAFT",
"PRUNE",
"DROP_RPC",
}
traceGossipEventSkipList = []string{
"ADD_PEER",
"REMOVE_PEER",
"JOIN",
"LEAVE",
}
)

func TestGossipSimulation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -84,9 +65,7 @@ func TestGossipSimulation(t *testing.T) {
},
pubsubConfig: &commons.PubsubConfig{
MsgValidator: &commons.MsgValidationConfig{},
Trace: &commons.PubsubTraceConfig{
Skiplist: traceEmptySkipList,
},
Trace: &commons.PubsubTraceConfig{},
Overlay: &commons.OverlayParams{
D: 3,
Dlow: 2,
Expand All @@ -110,9 +89,7 @@ func TestGossipSimulation(t *testing.T) {
},
pubsubConfig: &commons.PubsubConfig{
MsgValidator: &commons.MsgValidationConfig{},
Trace: &commons.PubsubTraceConfig{
Skiplist: traceEmptySkipList,
},
Trace: &commons.PubsubTraceConfig{},
Overlay: &commons.OverlayParams{
D: 4,
Dlow: 2,
Expand All @@ -136,9 +113,7 @@ func TestGossipSimulation(t *testing.T) {
},
pubsubConfig: &commons.PubsubConfig{
MsgValidator: &commons.MsgValidationConfig{},
Trace: &commons.PubsubTraceConfig{
Skiplist: traceEmptySkipList,
},
Trace: &commons.PubsubTraceConfig{},
},
},
groupsCfg: groupsCfgSimple36,
Expand All @@ -156,9 +131,7 @@ func TestGossipSimulation(t *testing.T) {
},
pubsubConfig: &commons.PubsubConfig{
MsgValidator: &commons.MsgValidationConfig{},
Trace: &commons.PubsubTraceConfig{
Skiplist: traceEmptySkipList,
},
Trace: &commons.PubsubTraceConfig{},
},
},
groupsCfg: groupsCfgSimple54,
Expand Down Expand Up @@ -380,21 +353,21 @@ type groupsCfg map[string]groupCfg
// baseConnectivity returns a base connectivity map for the groups,
// where each group member is connected to all other members of the group
// and to the relayers.
func (groups groupsCfg) baseConnectivity() connectivity {
conns := make(connectivity)
var relayerIDs []int
relayers, ok := groups["relayers"]
if ok {
relayerIDs = relayers.ids
}
for _, cfg := range groups {
connectIDs := append(cfg.ids, relayerIDs...)
for _, i := range cfg.ids {
conns[i] = connectIDs
}
}
return conns
}
// func (groups groupsCfg) baseConnectivity() connectivity {
// conns := make(connectivity)
// var relayerIDs []int
// relayers, ok := groups["relayers"]
// if ok {
// relayerIDs = relayers.ids
// }
// for _, cfg := range groups {
// connectIDs := append(cfg.ids, relayerIDs...)
// for _, i := range cfg.ids {
// conns[i] = connectIDs
// }
// }
// return conns
// }

func (groups groupsCfg) allToAllConnectivity() connectivity {
conns := make(connectivity)
Expand Down
22 changes: 0 additions & 22 deletions core/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/host"
libp2pnetwork "github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -82,27 +81,6 @@ func StartControllers(ctx context.Context, n int, gen Generator) ([]*Controller,
return controllers, msgRouters, valRouters, done, nil
}

func waitMinConnected(ctx context.Context, minConnected func(i int) int, backoff time.Duration, hosts ...host.Host) {
for i, h := range hosts {
connected := make([]peer.ID, 0)
min := minConnected(i)
for len(connected) < min && ctx.Err() == nil {
peers := h.Network().Peers()
for _, pid := range peers {
switch h.Network().Connectedness(pid) {
case libp2pnetwork.Connected:
connected = append(connected, pid)
default:
}
}
if len(connected) < min {
fmt.Printf("host %s connected to %d peers, waiting for %d\n", h.ID(), len(connected), min)
}
time.Sleep(backoff)
}
}
}

func waitControllersConnected(n int, controllers ...*Controller) {
for _, c := range controllers {
connected := make([]peer.ID, 0)
Expand Down

0 comments on commit 73506d1

Please sign in to comment.