Skip to content

Commit 6113752

Browse files
committed
fix: test with blocklist streams
1 parent b57a806 commit 6113752

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

pkg/p2p/libp2p/connections_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,14 @@ func TestWithBlocklistStreams(t *testing.T) {
10731073
expectPeersEventually(t, s2)
10741074
expectPeersEventually(t, s1)
10751075

1076+
err = spinlock.Wait(time.Second*5, func() bool {
1077+
b, _ := s1.Blocklisted(overlay2) // Check if s1 has blocklisted s2
1078+
return b
1079+
})
1080+
if err != nil {
1081+
t.Fatal("timed out waiting for s1 to blocklist s2")
1082+
}
1083+
10761084
if _, err := s2.Connect(ctx, s1_underlay); err == nil {
10771085
t.Fatal("expected error when connecting to blocklisted peer")
10781086
}

pkg/p2p/libp2p/libp2p.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,15 +1016,6 @@ func (s *Service) Connect(ctx context.Context, addrs []ma.Multiaddr) (address *b
10161016
return nil, fmt.Errorf("connect full close %w", err)
10171017
}
10181018

1019-
for _, addr := range addrs {
1020-
pingCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
1021-
defer cancel()
1022-
if _, err := s.Ping(pingCtx, addr); err != nil {
1023-
_ = s.Disconnect(overlay, "peer disconnected immediately after handshake")
1024-
return nil, p2p.ErrPeerNotFound
1025-
}
1026-
}
1027-
10281019
if !s.peers.Exists(overlay) {
10291020
return nil, p2p.ErrPeerNotFound
10301021
}

0 commit comments

Comments
 (0)