Skip to content

Commit 0808c88

Browse files
committed
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
2 parents a085a55 + faee330 commit 0808c88

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)