Skip to content

Commit fa02598

Browse files
author
MarcoFalke
committed
test: Add missing sync on send_version in peer_connect
1 parent 9b68c9b commit fa02598

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

test/functional/test_framework/p2p.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ def peer_connect_send_version(self, services):
364364
vt.addrFrom.port = 0
365365
self.on_connection_send_msg = vt # Will be sent in connection_made callback
366366

367-
def peer_connect(self, *args, services=P2P_SERVICES, send_version=True, **kwargs):
368-
create_conn = super().peer_connect(*args, **kwargs)
367+
def peer_connect(self, *, services=P2P_SERVICES, send_version, **kwargs):
368+
create_conn = super().peer_connect(**kwargs)
369369

370370
if send_version:
371371
self.peer_connect_send_version(services)

test/functional/test_framework/test_node.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, mat
634634
assert_msg += "with expected error " + expected_msg
635635
self._raise_assertion_error(assert_msg)
636636

637-
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
637+
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, send_version=True, **kwargs):
638638
"""Add an inbound p2p connection to the node.
639639
640640
This method adds the p2p connection to the self.p2ps list and also
@@ -645,9 +645,11 @@ def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs):
645645
kwargs['dstaddr'] = '127.0.0.1'
646646

647647
p2p_conn.p2p_connected_to_node = True
648-
p2p_conn.peer_connect(**kwargs, net=self.chain, timeout_factor=self.timeout_factor)()
648+
p2p_conn.peer_connect(**kwargs, send_version=send_version, net=self.chain, timeout_factor=self.timeout_factor)()
649649
self.p2ps.append(p2p_conn)
650650
p2p_conn.wait_until(lambda: p2p_conn.is_connected, check_connected=False)
651+
if send_version:
652+
p2p_conn.wait_until(lambda: not p2p_conn.on_connection_send_msg)
651653
if wait_for_verack:
652654
# Wait for the node to send us the version and verack
653655
p2p_conn.wait_for_verack()

0 commit comments

Comments
 (0)