mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge bitcoin/bitcoin#25443: test: Fail if connect_nodes fails
faee330c7b
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 ACKfaee330c7b
Tree-SHA512: 641ca8adcb9f5ff33239b143573bddc0dfde41dbd103751ee870f1572ca2469f6a0d4bab6693102454cd3e270ef8251d87fbfac48f6d8adac70d2d6bbffaae56
This commit is contained in:
commit
0808c88d7b
2 changed files with 15 additions and 5 deletions
|
@ -39,6 +39,14 @@ class SignetBasicTest(BitcoinTestFramework):
|
|||
shared_args3, shared_args3,
|
||||
]
|
||||
|
||||
def setup_network(self):
|
||||
self.setup_nodes()
|
||||
|
||||
# Setup the three signets, which are incompatible with each other
|
||||
self.connect_nodes(0, 1)
|
||||
self.connect_nodes(2, 3)
|
||||
self.connect_nodes(4, 5)
|
||||
|
||||
def run_test(self):
|
||||
self.log.info("basic tests using OP_TRUE challenge")
|
||||
|
||||
|
|
|
@ -581,6 +581,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
def connect_nodes(self, a, b):
|
||||
from_connection = self.nodes[a]
|
||||
to_connection = self.nodes[b]
|
||||
from_num_peers = 1 + len(from_connection.getpeerinfo())
|
||||
to_num_peers = 1 + len(to_connection.getpeerinfo())
|
||||
ip_port = "127.0.0.1:" + str(p2p_port(b))
|
||||
from_connection.addnode(ip_port, "onetry")
|
||||
# poll until version handshake complete to avoid race conditions
|
||||
|
@ -588,10 +590,10 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
# See comments in net_processing:
|
||||
# * Must have a version message before anything else
|
||||
# * Must have a verack message before anything else
|
||||
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
|
||||
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
|
||||
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
|
||||
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
|
||||
self.wait_until(lambda: sum(peer['version'] != 0 for peer in from_connection.getpeerinfo()) == from_num_peers)
|
||||
self.wait_until(lambda: sum(peer['version'] != 0 for peer in to_connection.getpeerinfo()) == to_num_peers)
|
||||
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()) == from_num_peers)
|
||||
self.wait_until(lambda: sum(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()) == to_num_peers)
|
||||
|
||||
def disconnect_nodes(self, a, b):
|
||||
def disconnect_nodes_helper(from_connection, node_num):
|
||||
|
@ -620,7 +622,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
raise
|
||||
|
||||
# wait to disconnect
|
||||
wait_until_helper(lambda: not get_peer_ids(), timeout=5)
|
||||
self.wait_until(lambda: not get_peer_ids(), timeout=5)
|
||||
|
||||
disconnect_nodes_helper(self.nodes[a], b)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue