Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#30362: test: p2p: check that connecting to ours…
Browse files Browse the repository at this point in the history
…elf leads to disconnect

5d2fb14 test: p2p: check that connecting to ourself leads to disconnect (Sebastian Falbesoner)

Pull request description:

  This small PR adds test coverage for the scenario of connecting to ourself, leading to an immediate disconnect:
  https://github.com/bitcoin/bitcoin/blob/2f6dca4d1c01ee47275a4292f128d714736837a1/src/net_processing.cpp#L3729-L3735

  This logic has been first introduced by Satoshi in October 2009, together with a couple of other changes and a version bump to "v0.1.6 BETA" (see commit cc0b4c3).

ACKs for top commit:
  kevkevinpal:
    tACK [5d2fb14](bitcoin/bitcoin@5d2fb14)
  maflcko:
    ACK 5d2fb14
  fjahr:
    tACK 5d2fb14
  tdb3:
    ACK 5d2fb14

Tree-SHA512: 30fb8c82cef94701affeca386ecd59daa32231635fa770fe225feb69fdab2ffedbfa157edd563f65099ec209f2dafffc1154f7f9292c2ea68bbd114750904875
  • Loading branch information
fanquake committed Jul 1, 2024
2 parents 2f6dca4 + 5d2fb14 commit b3c22e0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/functional/p2p_handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
NODE_WITNESS,
)
from test_framework.p2p import P2PInterface
from test_framework.util import p2p_port


# Desirable service flags for outbound non-pruned and pruned peers. Note that
Expand Down Expand Up @@ -88,6 +89,12 @@ def run_test(self):
with node.assert_debug_log([f"feeler connection completed"]):
self.add_outbound_connection(node, "feeler", NODE_NONE, wait_for_disconnect=True)

self.log.info("Check that connecting to ourself leads to immediate disconnect")
with node.assert_debug_log(["connected to self", "disconnecting"]):
node_listen_addr = f"127.0.0.1:{p2p_port(0)}"
node.addconnection(node_listen_addr, "outbound-full-relay", self.options.v2transport)
self.wait_until(lambda: len(node.getpeerinfo()) == 0)


if __name__ == '__main__':
P2PHandshakeTest().main()

0 comments on commit b3c22e0

Please sign in to comment.