mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
test: Avoid race after connect_nodes
This commit is contained in:
parent
0492b56e38
commit
fa04f26aa7
1 changed files with 13 additions and 12 deletions
|
@ -560,18 +560,19 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
self.nodes[i].process.wait(timeout)
|
self.nodes[i].process.wait(timeout)
|
||||||
|
|
||||||
def connect_nodes(self, a, b):
|
def connect_nodes(self, a, b):
|
||||||
def connect_nodes_helper(from_connection, node_num):
|
from_connection = self.nodes[a]
|
||||||
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
|
to_connection = self.nodes[b]
|
||||||
from_connection.addnode(ip_port, "onetry")
|
ip_port = "127.0.0.1:" + str(p2p_port(b))
|
||||||
# poll until version handshake complete to avoid race conditions
|
from_connection.addnode(ip_port, "onetry")
|
||||||
# with transaction relaying
|
# poll until version handshake complete to avoid race conditions
|
||||||
# See comments in net_processing:
|
# with transaction relaying
|
||||||
# * Must have a version message before anything else
|
# See comments in net_processing:
|
||||||
# * Must have a verack message before anything else
|
# * Must have a version message before anything else
|
||||||
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
|
# * Must have a verack message before anything else
|
||||||
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['version'] != 0 for peer in from_connection.getpeerinfo()))
|
||||||
|
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
|
||||||
connect_nodes_helper(self.nodes[a], b)
|
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(self, a, b):
|
||||||
def disconnect_nodes_helper(from_connection, node_num):
|
def disconnect_nodes_helper(from_connection, node_num):
|
||||||
|
|
Loading…
Add table
Reference in a new issue