test: Rename wait_until_helper to wait_until_helper_internal

Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
Fabian Jahr 2023-10-03 18:34:20 +02:00
parent a482f86779
commit 1ff1c34656
No known key found for this signature in database
GPG key ID: F13D1E9D890798CD
4 changed files with 10 additions and 10 deletions

View file

@ -77,7 +77,7 @@ from test_framework.messages import (
from test_framework.util import ( from test_framework.util import (
MAX_NODES, MAX_NODES,
p2p_port, p2p_port,
wait_until_helper, wait_until_helper_internal,
) )
logger = logging.getLogger("TestFramework.p2p") logger = logging.getLogger("TestFramework.p2p")
@ -466,7 +466,7 @@ class P2PInterface(P2PConnection):
assert self.is_connected assert self.is_connected
return test_function_in() return test_function_in()
wait_until_helper(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor) wait_until_helper_internal(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor)
def wait_for_connect(self, timeout=60): def wait_for_connect(self, timeout=60):
test_function = lambda: self.is_connected test_function = lambda: self.is_connected
@ -602,7 +602,7 @@ class NetworkThread(threading.Thread):
def close(self, timeout=10): def close(self, timeout=10):
"""Close the connections and network event loop.""" """Close the connections and network event loop."""
self.network_event_loop.call_soon_threadsafe(self.network_event_loop.stop) self.network_event_loop.call_soon_threadsafe(self.network_event_loop.stop)
wait_until_helper(lambda: not self.network_event_loop.is_running(), timeout=timeout) wait_until_helper_internal(lambda: not self.network_event_loop.is_running(), timeout=timeout)
self.network_event_loop.close() self.network_event_loop.close()
self.join(timeout) self.join(timeout)
# Safe to remove event loop. # Safe to remove event loop.

View file

@ -33,7 +33,7 @@ from .util import (
get_datadir_path, get_datadir_path,
initialize_datadir, initialize_datadir,
p2p_port, p2p_port,
wait_until_helper, wait_until_helper_internal,
) )
@ -747,7 +747,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
self.sync_mempools(nodes) self.sync_mempools(nodes)
def wait_until(self, test_function, timeout=60): def wait_until(self, test_function, timeout=60):
return wait_until_helper(test_function, timeout=timeout, timeout_factor=self.options.timeout_factor) return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.options.timeout_factor)
# Private helper methods. These should not be accessed by the subclass test scripts. # Private helper methods. These should not be accessed by the subclass test scripts.

View file

@ -36,7 +36,7 @@ from .util import (
get_auth_cookie, get_auth_cookie,
get_rpc_proxy, get_rpc_proxy,
rpc_url, rpc_url,
wait_until_helper, wait_until_helper_internal,
p2p_port, p2p_port,
) )
@ -253,7 +253,7 @@ class TestNode():
if self.version_is_at_least(190000): if self.version_is_at_least(190000):
# getmempoolinfo.loaded is available since commit # getmempoolinfo.loaded is available since commit
# bb8ae2c (version 0.19.0) # bb8ae2c (version 0.19.0)
wait_until_helper(lambda: rpc.getmempoolinfo()['loaded'], timeout_factor=self.timeout_factor) wait_until_helper_internal(lambda: rpc.getmempoolinfo()['loaded'], timeout_factor=self.timeout_factor)
# Wait for the node to finish reindex, block import, and # Wait for the node to finish reindex, block import, and
# loading the mempool. Usually importing happens fast or # loading the mempool. Usually importing happens fast or
# even "immediate" when the node is started. However, there # even "immediate" when the node is started. However, there
@ -407,7 +407,7 @@ class TestNode():
def wait_until_stopped(self, *, timeout=BITCOIND_PROC_WAIT_TIMEOUT, expect_error=False, **kwargs): 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 expected_ret_code = 1 if expect_error else 0 # Whether node shutdown return EXIT_FAILURE or EXIT_SUCCESS
wait_until_helper(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code, **kwargs), timeout=timeout, timeout_factor=self.timeout_factor) wait_until_helper_internal(lambda: self.is_node_stopped(expected_ret_code=expected_ret_code, **kwargs), timeout=timeout, timeout_factor=self.timeout_factor)
def replace_in_config(self, replacements): def replace_in_config(self, replacements):
""" """
@ -718,7 +718,7 @@ class TestNode():
p.peer_disconnect() p.peer_disconnect()
del self.p2ps[:] del self.p2ps[:]
wait_until_helper(lambda: self.num_test_p2p_connections() == 0, timeout_factor=self.timeout_factor) wait_until_helper_internal(lambda: self.num_test_p2p_connections() == 0, timeout_factor=self.timeout_factor)
def bumpmocktime(self, seconds): def bumpmocktime(self, seconds):
"""Fast forward using setmocktime to self.mocktime + seconds. Requires setmocktime to have """Fast forward using setmocktime to self.mocktime + seconds. Requires setmocktime to have

View file

@ -241,7 +241,7 @@ def satoshi_round(amount):
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN) return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0): def wait_until_helper_internal(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=None, timeout_factor=1.0):
"""Sleep until the predicate resolves to be True. """Sleep until the predicate resolves to be True.
Warning: Note that this method is not recommended to be used in tests as it is Warning: Note that this method is not recommended to be used in tests as it is