mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-27 14:30:24 +01:00
Merge bitcoin/bitcoin#28805: test: Make existing functional tests compatible with --v2transport
35fb9930adtest: enable v2 transport for p2p_timeouts.py (Martin Zumsande)2c1669c37atest: enable v2 transport for rpc_net.py (Sebastian Falbesoner)cc961c2695test: enable v2 transport for p2p_node_network_limited.py (Sebastian Falbesoner)3598a1b5c9test: enable --v2transport in combination with --usecli (Martin Zumsande)68a9001751test: persist -v2transport over restarts and respect -v2transport=0 (Martin Zumsande) Pull request description: This makes the functional test suite compatible with BIP324, so that `python3 test_runner.py --v2transport` should succeed (currently, 12 tests fail for me on master). Includes two commits by TheStack I found in an old discussion https://github.com/bitcoin/bitcoin/pull/28331#discussion_r1326714164 Note that even though all tests should pass, the python `p2p.py` module will do v2 connections only after the merge of #24748, so that for now only connections between two full nodes will actually run v2. Some of the fixed tests were added with `--v2transport` to the test runner. Though after #24748 we might also want to consider running the entire suite with `--v2transport` in some CI. ACKs for top commit: sipa: utACK35fb9930ad. Thanks for taking care of this. achow101: ACK35fb9930adtheStack: ACK35fb9930adstratospher: ACK35fb993. Tree-SHA512: 80dc0bf211fa525ff1d092043aea9f222f14c02e5832a548fb8b83b9ede1fcee03c5e8ade0d05c331bdaa492af9c1cf3d0f0b15b846673c6eacea82dd4cefbc3
This commit is contained in:
@@ -67,7 +67,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_path, *, 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):
|
||||
def __init__(self, i, datadir_path, *, 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, v2transport=False):
|
||||
"""
|
||||
Kwargs:
|
||||
start_perf (bool): If True, begin profiling the node with `perf` as soon as
|
||||
@@ -126,6 +126,12 @@ class TestNode():
|
||||
if self.version_is_at_least(239000):
|
||||
self.args.append("-loglevel=trace")
|
||||
|
||||
# Default behavior from global -v2transport flag is added to args to persist it over restarts.
|
||||
# May be overwritten in individual tests, using extra_args.
|
||||
self.default_to_v2 = v2transport
|
||||
if self.default_to_v2:
|
||||
self.args.append("-v2transport=1")
|
||||
|
||||
self.cli = TestNodeCLI(bitcoin_cli, self.datadir_path)
|
||||
self.use_cli = use_cli
|
||||
self.start_perf = start_perf
|
||||
@@ -198,6 +204,8 @@ class TestNode():
|
||||
if extra_args is None:
|
||||
extra_args = self.extra_args
|
||||
|
||||
self.use_v2transport = "-v2transport=1" in extra_args or (self.default_to_v2 and "-v2transport=0" not in extra_args)
|
||||
|
||||
# Add a new stdout and stderr file each time bitcoind is started
|
||||
if stderr is None:
|
||||
stderr = tempfile.NamedTemporaryFile(dir=self.stderr_dir, delete=False)
|
||||
@@ -782,15 +790,15 @@ class TestNodeCLI():
|
||||
results.append(dict(error=e))
|
||||
return results
|
||||
|
||||
def send_cli(self, command=None, *args, **kwargs):
|
||||
def send_cli(self, clicommand=None, *args, **kwargs):
|
||||
"""Run bitcoin-cli command. Deserializes returned string as python object."""
|
||||
pos_args = [arg_to_cli(arg) for arg in args]
|
||||
named_args = [str(key) + "=" + arg_to_cli(value) for (key, value) in kwargs.items()]
|
||||
p_args = [self.binary, f"-datadir={self.datadir}"] + self.options
|
||||
if named_args:
|
||||
p_args += ["-named"]
|
||||
if command is not None:
|
||||
p_args += [command]
|
||||
if clicommand is not None:
|
||||
p_args += [clicommand]
|
||||
p_args += pos_args + named_args
|
||||
self.log.debug("Running bitcoin-cli {}".format(p_args[2:]))
|
||||
process = subprocess.Popen(p_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
|
||||
Reference in New Issue
Block a user