mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 03:30:42 +02:00
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).
This commit is contained in:
parent
4a903741b0
commit
405ac819af
@ -726,7 +726,7 @@ class TestNode():
|
||||
|
||||
return p2p_conn
|
||||
|
||||
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):
|
||||
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):
|
||||
"""Add an outbound p2p connection from node. Must be an
|
||||
"outbound-full-relay", "block-relay-only", "addr-fetch" or "feeler" connection.
|
||||
|
||||
@ -773,7 +773,7 @@ class TestNode():
|
||||
if reconnect:
|
||||
p2p_conn.wait_for_reconnect()
|
||||
|
||||
if connection_type == "feeler":
|
||||
if connection_type == "feeler" or wait_for_disconnect:
|
||||
# feeler connections are closed as soon as the node receives a `version` message
|
||||
p2p_conn.wait_until(lambda: p2p_conn.message_count["version"] == 1, check_connected=False)
|
||||
p2p_conn.wait_until(lambda: not p2p_conn.is_connected, check_connected=False)
|
||||
|
Loading…
Reference in New Issue
Block a user