Skip to content

Commit 9860471

Browse files
committed
Merge bitcoin/bitcoin#29070: test: add TestNode wait_until helper
bf0f7db test: add TestNode wait_until helper (Nikodemas Tuckus) Pull request description: Add `wait_until` method that wraps the `wait_until_helper_internal` call. Closes bitcoin/bitcoin#29029. ACKs for top commit: maflcko: lgtm ACK bf0f7db mohamedawnallah: LGTM! Code Review ACK bitcoin/bitcoin@bf0f7db achow101: ACK bf0f7db BrandonOdiwuor: Code review ACK bf0f7db Tree-SHA512: 05aab589c814f51a14e1483eb57c10b88385714e3eb2d0973c0ee2877f2b963a76837f34215fe2e6bd1c8d735f5af7dd2098331e1eda28587f39e513bc6e1a6a
2 parents 4d7b787 + bf0f7db commit 9860471

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/functional/test_framework/test_node.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def wait_for_rpc_connection(self):
260260
if self.version_is_at_least(190000):
261261
# getmempoolinfo.loaded is available since commit
262262
# bb8ae2c (version 0.19.0)
263-
wait_until_helper_internal(lambda: rpc.getmempoolinfo()['loaded'], timeout_factor=self.timeout_factor)
263+
self.wait_until(lambda: rpc.getmempoolinfo()['loaded'])
264264
# Wait for the node to finish reindex, block import, and
265265
# loading the mempool. Usually importing happens fast or
266266
# even "immediate" when the node is started. However, there
@@ -414,7 +414,7 @@ def is_node_stopped(self, *, expected_stderr="", expected_ret_code=0):
414414

415415
def wait_until_stopped(self, *, timeout=BITCOIND_PROC_WAIT_TIMEOUT, expect_error=False, **kwargs):
416416
expected_ret_code = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
417-
wait_until_helper_internal(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code, **kwargs), timeout=timeout, timeout_factor=self.timeout_factor)
417+
self.wait_until(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code, **kwargs), timeout=timeout)
418418

419419
def replace_in_config(self, replacements):
420420
"""
@@ -534,8 +534,7 @@ def get_highest_peer_id():
534534

535535
initial_peer_id = get_highest_peer_id()
536536
yield
537-
wait_until_helper_internal(lambda: get_highest_peer_id() > initial_peer_id,
538-
timeout=timeout, timeout_factor=self.timeout_factor)
537+
self.wait_until(lambda: get_highest_peer_id() > initial_peer_id, timeout=timeout)
539538

540539
@contextlib.contextmanager
541540
def profile_with_perf(self, profile_name: str):
@@ -747,7 +746,7 @@ def disconnect_p2ps(self):
747746
p.peer_disconnect()
748747
del self.p2ps[:]
749748

750-
wait_until_helper_internal(lambda: self.num_test_p2p_connections() == 0, timeout_factor=self.timeout_factor)
749+
self.wait_until(lambda: self.num_test_p2p_connections() == 0)
751750

752751
def bumpmocktime(self, seconds):
753752
"""Fast forward using setmocktime to self.mocktime + seconds. Requires setmocktime to have
@@ -756,6 +755,9 @@ def bumpmocktime(self, seconds):
756755
self.mocktime += seconds
757756
self.setmocktime(self.mocktime)
758757

758+
def wait_until(self, test_function, timeout=60):
759+
return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.timeout_factor)
760+
759761

760762
class TestNodeCLIAttr:
761763
def __init__(self, cli, command):

0 commit comments

Comments
 (0)