Skip to content

Commit

Permalink
Gossipsub v2.0: Test sending IANNOUNCE out
Browse files Browse the repository at this point in the history
  • Loading branch information
ppopth committed Dec 17, 2024
1 parent 817a9a2 commit 999e46f
Show file tree
Hide file tree
Showing 2 changed files with 474 additions and 3 deletions.
19 changes: 16 additions & 3 deletions gossipsub_spam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ func TestGossipsubAttackSpamIWANT(t *testing.T) {
attacker := hosts[1]

// Set up gossipsub on the legit host
ps, err := NewGossipSub(ctx, legit)
params := DefaultGossipSubParams()
params.Dannounce = 0
ps, err := NewGossipSub(ctx, legit, WithGossipSubParams(params))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -149,7 +151,10 @@ func TestGossipsubAttackSpamIHAVE(t *testing.T) {
attacker := hosts[1]

// Set up gossipsub on the legit host
params := DefaultGossipSubParams()
params.Dannounce = 0
ps, err := NewGossipSub(ctx, legit,
WithGossipSubParams(params),
WithPeerScore(
&PeerScoreParams{
AppSpecificScore: func(peer.ID) float64 { return 0 },
Expand Down Expand Up @@ -300,7 +305,9 @@ func TestGossipsubAttackGRAFTNonExistentTopic(t *testing.T) {
attacker := hosts[1]

// Set up gossipsub on the legit host
ps, err := NewGossipSub(ctx, legit)
params := DefaultGossipSubParams()
params.Dannounce = 0
ps, err := NewGossipSub(ctx, legit, WithGossipSubParams(params))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -384,7 +391,10 @@ func TestGossipsubAttackGRAFTDuringBackoff(t *testing.T) {
attacker := hosts[1]

// Set up gossipsub on the legit host
params := DefaultGossipSubParams()
params.Dannounce = 0
ps, err := NewGossipSub(ctx, legit,
WithGossipSubParams(params),
WithPeerScore(
&PeerScoreParams{
AppSpecificScore: func(peer.ID) float64 { return 0 },
Expand Down Expand Up @@ -665,7 +675,10 @@ func TestGossipsubAttackInvalidMessageSpam(t *testing.T) {

// Set up gossipsub on the legit host
tracer := &gsAttackInvalidMsgTracer{}
gossipsubParams := DefaultGossipSubParams()
gossipsubParams.Dannounce = 0
ps, err := NewGossipSub(ctx, legit,
WithGossipSubParams(gossipsubParams),
WithEventTracer(tracer),
WithPeerScore(params, thresholds),
)
Expand Down Expand Up @@ -894,7 +907,7 @@ func TestGossipsubAttackSpamIDONTWANT(t *testing.T) {
type mockGSOnRead func(writeMsg func(*pb.RPC), irpc *pb.RPC)

func newMockGS(ctx context.Context, t *testing.T, attacker host.Host, onReadMsg mockGSOnRead) {
newMockGSWithVersion(ctx, t, attacker, protocol.ID("/meshsub/1.2.0"), onReadMsg)
newMockGSWithVersion(ctx, t, attacker, protocol.ID("/meshsub/2.0.0"), onReadMsg)
}

func newMockGSWithVersion(ctx context.Context, t *testing.T, attacker host.Host, gossipSubID protocol.ID, onReadMsg mockGSOnRead) {
Expand Down
Loading

0 comments on commit 999e46f

Please sign in to comment.