Skip to content

Commit 405ac81

Browse files
committed
test: p2p: support disconnect waiting for add_outbound_p2p_connection
Adds a new boolean parameter `wait_for_disconnect` to the `add_outbound_p2p_connection` method. If set, the node under test is checked to disconnect immediately after receiving the version message (same logic as for feeler connections).
1 parent 4a90374 commit 405ac81

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/functional/test_framework/test_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, send_version=Tru
726726

727727
return p2p_conn
728728

729-
def add_outbound_p2p_connection(self, p2p_conn, *, wait_for_verack=True, p2p_idx, connection_type="outbound-full-relay", supports_v2_p2p=None, advertise_v2_p2p=None, **kwargs):
729+
def add_outbound_p2p_connection(self, p2p_conn, *, wait_for_verack=True, wait_for_disconnect=False, p2p_idx, connection_type="outbound-full-relay", supports_v2_p2p=None, advertise_v2_p2p=None, **kwargs):
730730
"""Add an outbound p2p connection from node. Must be an
731731
"outbound-full-relay", "block-relay-only", "addr-fetch" or "feeler" connection.
732732
@@ -773,7 +773,7 @@ def addconnection_callback(address, port):
773773
if reconnect:
774774
p2p_conn.wait_for_reconnect()
775775

776-
if connection_type == "feeler":
776+
if connection_type == "feeler" or wait_for_disconnect:
777777
# feeler connections are closed as soon as the node receives a `version` message
778778
p2p_conn.wait_until(lambda: p2p_conn.message_count["version"] == 1, check_connected=False)
779779
p2p_conn.wait_until(lambda: not p2p_conn.is_connected, check_connected=False)

0 commit comments

Comments
 (0)