Skip to content

Commit 51fcdf5

Browse files
laanwjjagdeep sidhu
authored andcommitted
Merge bitcoin#25443: test: Fail if connect_nodes fails
faee330 test: Fail if connect_nodes fails (MacroFake) Pull request description: Currently, `connect_nodes` will return silently when the connection is disconnected while connecting. This is confusing, so fix it. Can be tested by reverting the signet test change and observing the failure when running the test. ACKs for top commit: laanwj: Tested ACK faee330 Tree-SHA512: 641ca8adcb9f5ff33239b143573bddc0dfde41dbd103751ee870f1572ca2469f6a0d4bab6693102454cd3e270ef8251d87fbfac48f6d8adac70d2d6bbffaae56
1 parent e658cf5 commit 51fcdf5

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
@@ -586,17 +586,19 @@ def wait_for_node_exit(self, i, timeout):
586586
def connect_nodes(self, a, b):
587587
from_connection = self.nodes[a]
588588
to_connection = self.nodes[b]
589+
from_num_peers = 1 + len(from_connection.getpeerinfo())
590+
to_num_peers = 1 + len(to_connection.getpeerinfo())
589591
ip_port = "127.0.0.1:" + str(p2p_port(b))
590592
from_connection.addnode(ip_port, "onetry")
591593
# poll until version handshake complete to avoid race conditions
592594
# with transaction relaying
593595
# See comments in net_processing:
594596
# * Must have a version message before anything else
595597
# * Must have a verack message before anything else
596-
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
597-
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
598-
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
599-
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
598+
self.wait_until(lambda: sum(peer['version'] != 0 for peer in from_connection.getpeerinfo()) == from_num_peers)
599+
self.wait_until(lambda: sum(peer['version'] != 0 for peer in to_connection.getpeerinfo()) == to_num_peers)
600+
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()) == from_num_peers)
601+
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()) == to_num_peers)
600602

601603
def disconnect_nodes(self, a, b):
602604
def disconnect_nodes_helper(from_connection, node_num):
@@ -625,7 +627,7 @@ def get_peer_ids():
625627
raise
626628

627629
# wait to disconnect
628-
wait_until_helper(lambda: not get_peer_ids(), timeout=5)
630+
self.wait_until(lambda: not get_peer_ids(), timeout=5)
629631

630632
disconnect_nodes_helper(self.nodes[a], b)
631633

0 commit comments

Comments
 (0)