Skip to content

Commit 5d2fb14

Browse files
committed
test: p2p: check that connecting to ourself leads to disconnect
The "connect to ourself" detection 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).
1 parent 2f6dca4 commit 5d2fb14

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)