mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-13 02:11:50 +02:00
test: add wait_for_connect to BitcoinTestFramework.connect_nodes
This commit is contained in:
parent
db7b5dfcc5
commit
7005a01c19
@ -586,7 +586,14 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||||||
def wait_for_node_exit(self, i, timeout):
|
def wait_for_node_exit(self, i, timeout):
|
||||||
self.nodes[i].process.wait(timeout)
|
self.nodes[i].process.wait(timeout)
|
||||||
|
|
||||||
def connect_nodes(self, a, b, *, peer_advertises_v2=None):
|
def connect_nodes(self, a, b, *, peer_advertises_v2=None, wait_for_connect: bool = True):
|
||||||
|
"""
|
||||||
|
Kwargs:
|
||||||
|
wait_for_connect: if True, block until the nodes are verified as connected. You might
|
||||||
|
want to disable this when using -stopatheight with one of the connected nodes,
|
||||||
|
since there will be a race between the actual connection and performing
|
||||||
|
the assertions before one node shuts down.
|
||||||
|
"""
|
||||||
from_connection = self.nodes[a]
|
from_connection = self.nodes[a]
|
||||||
to_connection = self.nodes[b]
|
to_connection = self.nodes[b]
|
||||||
from_num_peers = 1 + len(from_connection.getpeerinfo())
|
from_num_peers = 1 + len(from_connection.getpeerinfo())
|
||||||
@ -603,6 +610,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||||||
# compatibility with older clients
|
# compatibility with older clients
|
||||||
from_connection.addnode(ip_port, "onetry")
|
from_connection.addnode(ip_port, "onetry")
|
||||||
|
|
||||||
|
if not wait_for_connect:
|
||||||
|
return
|
||||||
|
|
||||||
# poll until version handshake complete to avoid race conditions
|
# poll until version handshake complete to avoid race conditions
|
||||||
# with transaction relaying
|
# with transaction relaying
|
||||||
# See comments in net_processing:
|
# See comments in net_processing:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user