Skip to content

Commit

Permalink
fix: blocklist (#4871)
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill authored Oct 22, 2024
1 parent c75fa3f commit cc37fe7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/p2p/libp2p/connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,34 @@ func TestBlocklisting(t *testing.T) {
expectPeers(t, s2)
}

func TestReverseBlocklist(t *testing.T) {
t.Parallel()

s1, overlay1 := newService(t, 1, libp2pServiceOpts{libp2pOpts: libp2p.Options{
FullNode: true,
}})
s2, overlay2 := newService(t, 1, libp2pServiceOpts{libp2pOpts: libp2p.Options{
FullNode: true,
}})

s1Addr := serviceUnderlayAddress(t, s1)

_, err := s2.Connect(context.Background(), s1Addr)
if err != nil {
t.Fatal(err)
}

expectPeers(t, s1, overlay2)
expectPeersEventually(t, s2, overlay1)

if err := s1.Blocklist(overlay2, 0, testBlocklistMsg); err != nil {
t.Fatal(err)
}

expectPeers(t, s1)
expectPeersEventually(t, s2)
}

func TestBlocklistedPeers(t *testing.T) {
t.Parallel()
s1, overlay1 := newService(t, 1, libp2pServiceOpts{libp2pOpts: libp2p.Options{
Expand Down
1 change: 1 addition & 0 deletions pkg/p2p/libp2p/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ func (s *Service) handleIncoming(stream network.Stream) {
}

peerUserAgent := appendSpace(s.peerUserAgent(s.ctx, peerID))
s.networkStatus.Store(int32(p2p.NetworkStatusAvailable))

loggerV1.Debug("stream handler: successfully connected to peer (inbound)", "addresses", i.BzzAddress.ShortString(), "light", i.LightString(), "user_agent", peerUserAgent)
s.logger.Debug("stream handler: successfully connected to peer (inbound)", "address", i.BzzAddress.Overlay, "light", i.LightString(), "user_agent", peerUserAgent)
Expand Down

0 comments on commit cc37fe7

Please sign in to comment.