aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@pm.me>2023-10-04 11:05:03 -0400
committerJames O'Beirne <james.obeirne@pm.me>2023-10-04 11:05:03 -0400
commit7005a01c19001ab5821731597656f8bc5e8c11e3 (patch)
treedae9574593998c07a7b3e8b3861003e3117f0fc7 /test/functional/test_framework
parentdb7b5dfcc502a8a81c51f56fe753990ae8b3a202 (diff)
downloadbitcoin-7005a01c19001ab5821731597656f8bc5e8c11e3.tar.xz
test: add wait_for_connect to BitcoinTestFramework.connect_nodes
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-xtest/functional/test_framework/test_framework.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index ab7fed335c..a34c34713e 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -586,7 +586,14 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def wait_for_node_exit(self, i, 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]
to_connection = self.nodes[b]
from_num_peers = 1 + len(from_connection.getpeerinfo())
@@ -603,6 +610,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# compatibility with older clients
from_connection.addnode(ip_port, "onetry")
+ if not wait_for_connect:
+ return
+
# poll until version handshake complete to avoid race conditions
# with transaction relaying
# See comments in net_processing: