aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2023-12-14 14:11:00 -0500
committerAva Chow <github@achow101.com>2023-12-14 14:19:16 -0500
commit986047170892c9482ccbc21f05bf4f1499b3089d (patch)
treef17647171c8f2435d69b8ed201b633bcad121038
parent4d7b787ad630495a02092269339fedcef31c24d4 (diff)
parentbf0f7dbec6590a54ec890e7a2ca5d85427995334 (diff)
downloadbitcoin-986047170892c9482ccbc21f05bf4f1499b3089d.tar.xz
Merge bitcoin/bitcoin#29070: test: add TestNode wait_until helper
bf0f7dbec6590a54ec890e7a2ca5d85427995334 test: add TestNode wait_until helper (Nikodemas Tuckus) Pull request description: Add `wait_until` method that wraps the `wait_until_helper_internal` call. Closes https://github.com/bitcoin/bitcoin/issues/29029. ACKs for top commit: maflcko: lgtm ACK bf0f7dbec6590a54ec890e7a2ca5d85427995334 mohamedawnallah: LGTM! Code Review ACK https://github.com/bitcoin/bitcoin/commit/bf0f7dbec6590a54ec890e7a2ca5d85427995334 achow101: ACK bf0f7dbec6590a54ec890e7a2ca5d85427995334 BrandonOdiwuor: Code review ACK bf0f7dbec6590a54ec890e7a2ca5d85427995334 Tree-SHA512: 05aab589c814f51a14e1483eb57c10b88385714e3eb2d0973c0ee2877f2b963a76837f34215fe2e6bd1c8d735f5af7dd2098331e1eda28587f39e513bc6e1a6a
-rwxr-xr-xtest/functional/test_framework/test_node.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 90c1213deb..b3f777b9df 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -260,7 +260,7 @@ class TestNode():
if self.version_is_at_least(190000):
# getmempoolinfo.loaded is available since commit
# bb8ae2c (version 0.19.0)
- wait_until_helper_internal(lambda: rpc.getmempoolinfo()['loaded'], timeout_factor=self.timeout_factor)
+ self.wait_until(lambda: rpc.getmempoolinfo()['loaded'])
# Wait for the node to finish reindex, block import, and
# loading the mempool. Usually importing happens fast or
# even "immediate" when the node is started. However, there
@@ -414,7 +414,7 @@ class TestNode():
def wait_until_stopped(self, *, timeout=BITCOIND_PROC_WAIT_TIMEOUT, expect_error=False, **kwargs):
expected_ret_code = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
- wait_until_helper_internal(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code, **kwargs), timeout=timeout, timeout_factor=self.timeout_factor)
+ self.wait_until(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code, **kwargs), timeout=timeout)
def replace_in_config(self, replacements):
"""
@@ -534,8 +534,7 @@ class TestNode():
initial_peer_id = get_highest_peer_id()
yield
- wait_until_helper_internal(lambda: get_highest_peer_id() > initial_peer_id,
- timeout=timeout, timeout_factor=self.timeout_factor)
+ self.wait_until(lambda: get_highest_peer_id() > initial_peer_id, timeout=timeout)
@contextlib.contextmanager
def profile_with_perf(self, profile_name: str):
@@ -747,7 +746,7 @@ class TestNode():
p.peer_disconnect()
del self.p2ps[:]
- wait_until_helper_internal(lambda: self.num_test_p2p_connections() == 0, timeout_factor=self.timeout_factor)
+ self.wait_until(lambda: self.num_test_p2p_connections() == 0)
def bumpmocktime(self, seconds):
"""Fast forward using setmocktime to self.mocktime + seconds. Requires setmocktime to have
@@ -756,6 +755,9 @@ class TestNode():
self.mocktime += seconds
self.setmocktime(self.mocktime)
+ def wait_until(self, test_function, timeout=60):
+ return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.timeout_factor)
+
class TestNodeCLIAttr:
def __init__(self, cli, command):