Skip to content

Commit b3c22e0

Browse files
committed
Merge bitcoin/bitcoin#30362: test: p2p: check that connecting to ourself 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
2 parents 2f6dca4 + 5d2fb14 commit b3c22e0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/functional/p2p_handshake.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
NODE_WITNESS,
1818
)
1919
from test_framework.p2p import P2PInterface
20+
from test_framework.util import p2p_port
2021

2122

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

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

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

0 commit comments

Comments
 (0)