Merge bitcoin/bitcoin#33698: test: Use same rpc timeout for authproxy and cli

66667d6512 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 de0833c596..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 66667d6512
  stickies-v:
    tACK 66667d6512

Tree-SHA512: c8c21d8b9fb60ab192e3bbd45b317b96a40e10bf03704148613ac3cbdaae4abc2c03c4afbd504309ea0958201267c0d2a4bc5b40aa020917175c47e080ffe292
This commit is contained in:
merge-script
2025-10-30 16:36:51 +00:00

View File

@@ -106,7 +106,8 @@ class TestNode():
self.stderr_dir = self.datadir_path / "stderr"
self.chain = chain
self.rpchost = rpchost
self.rpc_timeout = timewait
self.rpc_timeout = timewait # Already multiplied by timeout_factor
self.timeout_factor = timeout_factor
self.binaries = binaries
self.coverage_dir = coverage_dir
self.cwd = cwd
@@ -175,7 +176,11 @@ class TestNode():
self.args.append("-v2transport=0")
# if v2transport is requested via global flag but not supported for node version, ignore it
self.cli = TestNodeCLI(binaries, self.datadir_path)
self.cli = TestNodeCLI(
binaries,
self.datadir_path,
self.rpc_timeout // 2, # timeout identical to the one used in self._rpc
)
self.use_cli = use_cli
self.start_perf = start_perf
@@ -190,7 +195,6 @@ class TestNode():
self.perf_subprocesses = {}
self.p2ps = []
self.timeout_factor = timeout_factor
self.mocktime = None
@@ -919,16 +923,17 @@ def arg_to_cli(arg):
class TestNodeCLI():
"""Interface to bitcoin-cli for an individual node"""
def __init__(self, binaries, datadir):
def __init__(self, binaries, datadir, rpc_timeout):
self.options = []
self.binaries = binaries
self.datadir = datadir
self.rpc_timeout = rpc_timeout
self.input = None
self.log = logging.getLogger('TestFramework.bitcoincli')
def __call__(self, *options, input=None):
# TestNodeCLI is callable with bitcoin-cli command-line options
cli = TestNodeCLI(self.binaries, self.datadir)
cli = TestNodeCLI(self.binaries, self.datadir, self.rpc_timeout)
cli.options = [str(o) for o in options]
cli.input = input
return cli
@@ -949,7 +954,10 @@ class TestNodeCLI():
"""Run bitcoin-cli command. Deserializes returned string as python object."""
pos_args = [arg_to_cli(arg) for arg in args]
named_args = [key + "=" + arg_to_cli(value) for (key, value) in kwargs.items() if value is not None]
p_args = self.binaries.rpc_argv() + [f"-datadir={self.datadir}"] + self.options
p_args = self.binaries.rpc_argv() + [
f"-datadir={self.datadir}",
f"-rpcclienttimeout={int(self.rpc_timeout)}",
] + self.options
if named_args:
p_args += ["-named"]
base_arg_pos = len(p_args)