Skip to content

Commit

Permalink
test: Rename wait_until_helper to wait_until_helper_internal
Browse files Browse the repository at this point in the history
Co-authored-by: MarcoFalke <falke.marco@gmail.com>
  • Loading branch information
fjahr and MarcoFalke committed Oct 3, 2023
1 parent 3d5c3fb commit 69fbb77
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions test/functional/test_framework/p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
from test_framework.util import (
MAX_NODES,
p2p_port,
wait_until_helper,
wait_until_helper_internal,
)

logger = logging.getLogger("TestFramework.p2p")
Expand Down Expand Up @@ -466,7 +466,7 @@ def test_function():
assert self.is_connected
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):
test_function = lambda: self.is_connected
Expand Down Expand Up @@ -602,7 +602,7 @@ def run(self):
def close(self, timeout=10):
"""Close the connections and network event loop."""
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.join(timeout)
# Safe to remove event loop.
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
get_datadir_path,
initialize_datadir,
p2p_port,
wait_until_helper,
wait_until_helper_internal,
)


Expand Down Expand Up @@ -737,7 +737,7 @@ def sync_all(self, nodes=None):
self.sync_mempools(nodes)

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.

Expand Down
8 changes: 4 additions & 4 deletions test/functional/test_framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
get_auth_cookie,
get_rpc_proxy,
rpc_url,
wait_until_helper,
wait_until_helper_internal,
p2p_port,
)

Expand Down Expand Up @@ -248,7 +248,7 @@ def wait_for_rpc_connection(self):
if self.version_is_at_least(190000):
# getmempoolinfo.loaded is available since commit
# 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
# loading the mempool. Usually importing happens fast or
# even "immediate" when the node is started. However, there
Expand Down Expand Up @@ -402,7 +402,7 @@ def is_node_stopped(self, *, expected_stderr="", expected_ret_code=0):

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(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):
"""
Expand Down Expand Up @@ -713,7 +713,7 @@ def disconnect_p2ps(self):
p.peer_disconnect()
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):
"""Fast forward using setmocktime to self.mocktime + seconds. Requires setmocktime to have
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def satoshi_round(amount):
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.
Warning: Note that this method is not recommended to be used in tests as it is
Expand Down

0 comments on commit 69fbb77

Please sign in to comment.