mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-25 21:39:05 +01:00
test: Add capability to disable RPC timeout in functional tests.
Modifies the existing --factor flag to --timeout-factor to better express intent. Adds rules to disable timeout if --timeout-factor is set to 0. Modfies --timeout-factor help doc to inform users about this feature.
This commit is contained in:
@@ -62,7 +62,7 @@ class TestNode():
|
||||
To make things easier for the test writer, any unrecognised messages will
|
||||
be dispatched to the RPC connection."""
|
||||
|
||||
def __init__(self, i, datadir, *, chain, rpchost, timewait, factor, bitcoind, bitcoin_cli, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False, version=None, descriptors=False):
|
||||
def __init__(self, i, datadir, *, chain, rpchost, timewait, timeout_factor, bitcoind, bitcoin_cli, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False, version=None, descriptors=False):
|
||||
"""
|
||||
Kwargs:
|
||||
start_perf (bool): If True, begin profiling the node with `perf` as soon as
|
||||
@@ -128,7 +128,7 @@ class TestNode():
|
||||
self.perf_subprocesses = {}
|
||||
|
||||
self.p2ps = []
|
||||
self.factor = factor
|
||||
self.timeout_factor = timeout_factor
|
||||
|
||||
AddressKeyPair = collections.namedtuple('AddressKeyPair', ['address', 'key'])
|
||||
PRIV_KEYS = [
|
||||
@@ -241,7 +241,7 @@ class TestNode():
|
||||
# The wait is done here to make tests as robust as possible
|
||||
# and prevent racy tests and intermittent failures as much
|
||||
# as possible. Some tests might not need this, but the
|
||||
# overhead is trivial, and the added gurantees are worth
|
||||
# overhead is trivial, and the added guarantees are worth
|
||||
# the minimal performance cost.
|
||||
self.log.debug("RPC successfully started")
|
||||
if self.use_cli:
|
||||
@@ -349,13 +349,13 @@ class TestNode():
|
||||
return True
|
||||
|
||||
def wait_until_stopped(self, timeout=BITCOIND_PROC_WAIT_TIMEOUT):
|
||||
wait_until(self.is_node_stopped, timeout=timeout, factor=self.factor)
|
||||
wait_until(self.is_node_stopped, timeout=timeout, timeout_factor=self.timeout_factor)
|
||||
|
||||
@contextlib.contextmanager
|
||||
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
|
||||
if unexpected_msgs is None:
|
||||
unexpected_msgs = []
|
||||
time_end = time.time() + timeout * self.factor
|
||||
time_end = time.time() + timeout * self.timeout_factor
|
||||
debug_log = os.path.join(self.datadir, self.chain, 'debug.log')
|
||||
with open(debug_log, encoding='utf-8') as dl:
|
||||
dl.seek(0, 2)
|
||||
@@ -512,7 +512,7 @@ class TestNode():
|
||||
if 'dstaddr' not in kwargs:
|
||||
kwargs['dstaddr'] = '127.0.0.1'
|
||||
|
||||
p2p_conn.peer_connect(**kwargs, net=self.chain, factor=self.factor)()
|
||||
p2p_conn.peer_connect(**kwargs, net=self.chain, timeout_factor=self.timeout_factor)()
|
||||
self.p2ps.append(p2p_conn)
|
||||
if wait_for_verack:
|
||||
# Wait for the node to send us the version and verack
|
||||
@@ -526,7 +526,7 @@ class TestNode():
|
||||
# transaction that will be added to the mempool as soon as we return here.
|
||||
#
|
||||
# So syncing here is redundant when we only want to send a message, but the cost is low (a few milliseconds)
|
||||
# in comparision to the upside of making tests less fragile and unexpected intermittent errors less likely.
|
||||
# in comparison to the upside of making tests less fragile and unexpected intermittent errors less likely.
|
||||
p2p_conn.sync_with_ping()
|
||||
|
||||
return p2p_conn
|
||||
|
||||
Reference in New Issue
Block a user