mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Merge bitcoin/bitcoin#22817: test: Avoid race after connect_nodes
fa04f26aa7
test: Avoid race after connect_nodes (MarcoFalke) Pull request description: Wait until the connection is fully established on both sides (verack). Fixes #22714 ACKs for top commit: kiminuo: utACKfa04f26aa7
Tree-SHA512: bc2c44b44b688086ff84046924cf5251dd625584e93ce8fa17de27023855b32f3bb55109b846abbcec775e2836c7f3c5a81d6b4aff7c4ac065b9aefa044c1883
This commit is contained in:
commit
442e32e117
1 changed files with 13 additions and 12 deletions
|
@ -560,18 +560,19 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
self.nodes[i].process.wait(timeout)
|
||||
|
||||
def connect_nodes(self, a, b):
|
||||
def connect_nodes_helper(from_connection, node_num):
|
||||
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
|
||||
from_connection.addnode(ip_port, "onetry")
|
||||
# poll until version handshake complete to avoid race conditions
|
||||
# with transaction relaying
|
||||
# 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['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
|
||||
|
||||
connect_nodes_helper(self.nodes[a], b)
|
||||
from_connection = self.nodes[a]
|
||||
to_connection = self.nodes[b]
|
||||
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
|
||||
# with transaction relaying
|
||||
# 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()))
|
||||
|
||||
def disconnect_nodes(self, a, b):
|
||||
def disconnect_nodes_helper(from_connection, node_num):
|
||||
|
|
Loading…
Add table
Reference in a new issue