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. The issue still persists for positional args,
but the existing test "wallet_labels.py" affected by this can
be changed to use named args instead.

This also makes wallet_labels.py --usecli no longer fail.
This commit is contained in:
Martin Zumsande 2025-04-18 17:41:12 -04:00
parent 75b58471db
commit abcec01ed5
2 changed files with 3 additions and 4 deletions

View file

@ -899,7 +899,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 = [str(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"]
@ -952,8 +952,8 @@ class RPCOverloadWrapper():
def addmultisigaddress(self, nrequired, keys, label=None, address_type=None):
wallet_info = self.getwalletinfo()
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type)
cms = self.createmultisig(nrequired, keys, address_type)
return self.__getattr__('addmultisigaddress')(nrequired, keys, label, address_type=address_type)
cms = self.createmultisig(nrequired, keys, address_type=address_type)
req = [{
'desc': cms['descriptor'],
'timestamp': 0,

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()