Skip to content

Commit 6f35969

Browse files
committed
Merge bitcoin#33698: test: Use same rpc timeout for authproxy and cli
66667d6 test: Use same rpc timeout for authproxy and cli (MarcoFalke) Pull request description: It seems odd to use different timeouts (and timeout factors) depending on whether the Python RPC proxy is used, or the bitcoin rpc command line interface. Fix it by using the same timeout. This can be tested by introducing a timeout error and checking it happens with and without `--usecli` after the exact same time. Example timeout error: ```diff diff --git a/test/functional/mining_template_verification.py b/test/functional/mining_template_verification.py index de0833c..e0f93a2b1e 100755 --- a/test/functional/mining_template_verification.py +++ b/test/functional/mining_template_verification.py @@ -173,7 +173,7 @@ class MiningTemplateVerificationTest(BitcoinTestFramework): self.log.info("Submitting this block should succeed") assert_equal(node.submitblock(block.serialize().hex()), None) - node.waitforblockheight(2) + node.waitforblockheight(200000) def transaction_test(self, node, block_0_height, tx): self.log.info("make block template with a transaction") ``` Example cmd: `./bld-cmake/test/functional/mining_template_verification.py --timeout-factor=0.1 --usecli`. ACKs for top commit: brunoerg: ACK 66667d6 stickies-v: tACK 66667d6 Tree-SHA512: c8c21d8b9fb60ab192e3bbd45b317b96a40e10bf03704148613ac3cbdaae4abc2c03c4afbd504309ea0958201267c0d2a4bc5b40aa020917175c47e080ffe292
2 parents c281bb6 + 66667d6 commit 6f35969

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

test/functional/test_framework/test_node.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor,
106106
self.stderr_dir = self.datadir_path / "stderr"
107107
self.chain = chain
108108
self.rpchost = rpchost
109-
self.rpc_timeout = timewait
109+
self.rpc_timeout = timewait # Already multiplied by timeout_factor
110+
self.timeout_factor = timeout_factor
110111
self.binaries = binaries
111112
self.coverage_dir = coverage_dir
112113
self.cwd = cwd
@@ -175,7 +176,11 @@ def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor,
175176
self.args.append("-v2transport=0")
176177
# if v2transport is requested via global flag but not supported for node version, ignore it
177178

178-
self.cli = TestNodeCLI(binaries, self.datadir_path)
179+
self.cli = TestNodeCLI(
180+
binaries,
181+
self.datadir_path,
182+
self.rpc_timeout // 2, # timeout identical to the one used in self._rpc
183+
)
179184
self.use_cli = use_cli
180185
self.start_perf = start_perf
181186

@@ -190,7 +195,6 @@ def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor,
190195
self.perf_subprocesses = {}
191196

192197
self.p2ps = []
193-
self.timeout_factor = timeout_factor
194198

195199
self.mocktime = None
196200

@@ -919,16 +923,17 @@ def arg_to_cli(arg):
919923

920924
class TestNodeCLI():
921925
"""Interface to bitcoin-cli for an individual node"""
922-
def __init__(self, binaries, datadir):
926+
def __init__(self, binaries, datadir, rpc_timeout):
923927
self.options = []
924928
self.binaries = binaries
925929
self.datadir = datadir
930+
self.rpc_timeout = rpc_timeout
926931
self.input = None
927932
self.log = logging.getLogger('TestFramework.bitcoincli')
928933

929934
def __call__(self, *options, input=None):
930935
# TestNodeCLI is callable with bitcoin-cli command-line options
931-
cli = TestNodeCLI(self.binaries, self.datadir)
936+
cli = TestNodeCLI(self.binaries, self.datadir, self.rpc_timeout)
932937
cli.options = [str(o) for o in options]
933938
cli.input = input
934939
return cli
@@ -949,7 +954,10 @@ def send_cli(self, clicommand=None, *args, **kwargs):
949954
"""Run bitcoin-cli command. Deserializes returned string as python object."""
950955
pos_args = [arg_to_cli(arg) for arg in args]
951956
named_args = [key + "=" + arg_to_cli(value) for (key, value) in kwargs.items() if value is not None]
952-
p_args = self.binaries.rpc_argv() + [f"-datadir={self.datadir}"] + self.options
957+
p_args = self.binaries.rpc_argv() + [
958+
f"-datadir={self.datadir}",
959+
f"-rpcclienttimeout={int(self.rpc_timeout)}",
960+
] + self.options
953961
if named_args:
954962
p_args += ["-named"]
955963
base_arg_pos = len(p_args)

0 commit comments

Comments
 (0)