Skip to content

Commit faee330

Browse files
author
MacroFake
committed
test: Fail if connect_nodes fails
Also replace the use of wait_until_helper, which is not allowed to be called directly. Otherwise, --timeout-factor will not be honoured.
1 parent e3b06e8 commit faee330

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

test/functional/feature_signet.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def set_test_params(self):
3939
shared_args3, shared_args3,
4040
]
4141

42+
def setup_network(self):
43+
self.setup_nodes()
44+
45+
# Setup the three signets, which are incompatible with each other
46+
self.connect_nodes(0, 1)
47+
self.connect_nodes(2, 3)
48+
self.connect_nodes(4, 5)
49+
4250
def run_test(self):
4351
self.log.info("basic tests using OP_TRUE challenge")
4452

test/functional/test_framework/test_framework.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,17 +581,19 @@ def wait_for_node_exit(self, i, timeout):
581581
def connect_nodes(self, a, b):
582582
from_connection = self.nodes[a]
583583
to_connection = self.nodes[b]
584+
from_num_peers = 1 + len(from_connection.getpeerinfo())
585+
to_num_peers = 1 + len(to_connection.getpeerinfo())
584586
ip_port = "127.0.0.1:" + str(p2p_port(b))
585587
from_connection.addnode(ip_port, "onetry")
586588
# poll until version handshake complete to avoid race conditions
587589
# with transaction relaying
588590
# See comments in net_processing:
589591
# * Must have a version message before anything else
590592
# * Must have a verack message before anything else
591-
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
592-
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
593-
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
594-
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
593+
self.wait_until(lambda: sum(peer['version'] != 0 for peer in from_connection.getpeerinfo()) == from_num_peers)
594+
self.wait_until(lambda: sum(peer['version'] != 0 for peer in to_connection.getpeerinfo()) == to_num_peers)
595+
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()) == from_num_peers)
596+
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()) == to_num_peers)
595597

596598
def disconnect_nodes(self, a, b):
597599
def disconnect_nodes_helper(from_connection, node_num):
@@ -620,7 +622,7 @@ def get_peer_ids():
620622
raise
621623

622624
# wait to disconnect
623-
wait_until_helper(lambda: not get_peer_ids(), timeout=5)
625+
self.wait_until(lambda: not get_peer_ids(), timeout=5)
624626

625627
disconnect_nodes_helper(self.nodes[a], b)
626628

0 commit comments

Comments
 (0)