Skip to content

Commit fa04f26

Browse files
author
MarcoFalke
committed
test: Avoid race after connect_nodes
1 parent 0492b56 commit fa04f26

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -560,18 +560,19 @@ def wait_for_node_exit(self, i, timeout):
560560
self.nodes[i].process.wait(timeout)
561561

562562
def connect_nodes(self, a, b):
563-
def connect_nodes_helper(from_connection, node_num):
564-
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
565-
from_connection.addnode(ip_port, "onetry")
566-
# poll until version handshake complete to avoid race conditions
567-
# with transaction relaying
568-
# See comments in net_processing:
569-
# * Must have a version message before anything else
570-
# * Must have a verack message before anything else
571-
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
572-
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
573-
574-
connect_nodes_helper(self.nodes[a], b)
563+
from_connection = self.nodes[a]
564+
to_connection = self.nodes[b]
565+
ip_port = "127.0.0.1:" + str(p2p_port(b))
566+
from_connection.addnode(ip_port, "onetry")
567+
# poll until version handshake complete to avoid race conditions
568+
# with transaction relaying
569+
# See comments in net_processing:
570+
# * Must have a version message before anything else
571+
# * Must have a verack message before anything else
572+
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
573+
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
574+
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
575+
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
575576

576577
def disconnect_nodes(self, a, b):
577578
def disconnect_nodes_helper(from_connection, node_num):

0 commit comments

Comments
 (0)