0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-13 11:25:02 -05:00

test: Add missing sync on send_version in peer_connect

This commit is contained in:
MarcoFalke 2023-11-03 13:30:54 +01:00
parent 9b68c9b85e
commit fa02598469
No known key found for this signature in database
2 changed files with 6 additions and 4 deletions

View file

@ -364,8 +364,8 @@ class P2PInterface(P2PConnection):
vt.addrFrom.port = 0 vt.addrFrom.port = 0
self.on_connection_send_msg = vt # Will be sent in connection_made callback self.on_connection_send_msg = vt # Will be sent in connection_made callback
def peer_connect(self, *args, services=P2P_SERVICES, send_version=True, **kwargs): def peer_connect(self, *, services=P2P_SERVICES, send_version, **kwargs):
create_conn = super().peer_connect(*args, **kwargs) create_conn = super().peer_connect(**kwargs)
if send_version: if send_version:
self.peer_connect_send_version(services) self.peer_connect_send_version(services)

View file

@ -634,7 +634,7 @@ class TestNode():
assert_msg += "with expected error " + expected_msg assert_msg += "with expected error " + expected_msg
self._raise_assertion_error(assert_msg) self._raise_assertion_error(assert_msg)
def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, **kwargs): def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, send_version=True, **kwargs):
"""Add an inbound p2p connection to the node. """Add an inbound p2p connection to the node.
This method adds the p2p connection to the self.p2ps list and also This method adds the p2p connection to the self.p2ps list and also
@ -645,9 +645,11 @@ class TestNode():
kwargs['dstaddr'] = '127.0.0.1' kwargs['dstaddr'] = '127.0.0.1'
p2p_conn.p2p_connected_to_node = True p2p_conn.p2p_connected_to_node = True
p2p_conn.peer_connect(**kwargs, net=self.chain, timeout_factor=self.timeout_factor)() p2p_conn.peer_connect(**kwargs, send_version=send_version, net=self.chain, timeout_factor=self.timeout_factor)()
self.p2ps.append(p2p_conn) self.p2ps.append(p2p_conn)
p2p_conn.wait_until(lambda: p2p_conn.is_connected, check_connected=False) p2p_conn.wait_until(lambda: p2p_conn.is_connected, check_connected=False)
if send_version:
p2p_conn.wait_until(lambda: not p2p_conn.on_connection_send_msg)
if wait_for_verack: if wait_for_verack:
# Wait for the node to send us the version and verack # Wait for the node to send us the version and verack
p2p_conn.wait_for_verack() p2p_conn.wait_for_verack()