Skip to content

Commit b3a3d78

Browse files
laanwjpanleone
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 72709b9 commit b3a3d78

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,19 @@ def wait_for_node_exit(self, i, timeout):
343343
def connect_nodes(self, a, b):
344344
from_connection = self.nodes[a]
345345
to_connection = self.nodes[b]
346+
from_num_peers = 1 + len(from_connection.getpeerinfo())
347+
to_num_peers = 1 + len(to_connection.getpeerinfo())
346348
ip_port = "127.0.0.1:" + str(p2p_port(b))
347349
from_connection.addnode(ip_port, "onetry")
348350
# poll until version handshake complete to avoid race conditions
349351
# with transaction relaying
350352
# See comments in net_processing:
351353
# * Must have a version message before anything else
352354
# * Must have a verack message before anything else
353-
wait_until(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
354-
wait_until(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
355-
wait_until(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
356-
wait_until(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
355+
wait_until(lambda: sum(peer['version'] != 0 for peer in from_connection.getpeerinfo()) == from_num_peers)
356+
wait_until(lambda: sum(peer['version'] != 0 for peer in to_connection.getpeerinfo()) == to_num_peers)
357+
wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()) == from_num_peers)
358+
wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()) == to_num_peers)
357359

358360
def disconnect_nodes(self, a, b):
359361
def disconnect_nodes_helper(from_connection, node_num):

0 commit comments

Comments
 (0)