test: Don't send empty named args with cli

If python passed None for an optional (i.e. 'null' is
sent), this will lead to the arg being interpreted as not
provided by bitcoind - except for string args, for which the arg is
interpreted as as 'null' string. Bypass this by not sending
named args to bitcoin-cli - so that the default value will
actually be used.

Also drops an unnecessary str() conversion, kwargs keys
are always strings.
This commit is contained in:
Martin Zumsande
2025-04-18 17:41:12 -04:00
parent cca422060e
commit 54d28722ba
2 changed files with 1 additions and 2 deletions

View File

@ -918,7 +918,7 @@ class TestNodeCLI():
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()]
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
if named_args:
p_args += ["-named"]

View File

@ -78,7 +78,6 @@ class AddressTypeTest(BitcoinTestFramework):
]
# whitelist peers to speed up tx relay / mempool sync
self.noban_tx_relay = True
self.supports_cli = False
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()