From fa96f93f056efffe3de5e5141f0e0927f8eb0abd Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 11 Jan 2023 17:58:45 +0100 Subject: [PATCH 1/2] test: Add test for missing and omitted required arg --- test/functional/rpc_invalid_address_message.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/functional/rpc_invalid_address_message.py b/test/functional/rpc_invalid_address_message.py index 452f857a44f..0c29efb85a1 100755 --- a/test/functional/rpc_invalid_address_message.py +++ b/test/functional/rpc_invalid_address_message.py @@ -95,15 +95,19 @@ class InvalidAddressErrorMessageTest(BitcoinTestFramework): self.check_invalid(INVALID_ADDRESS, 'Not a valid Bech32 or Base58 encoding') self.check_invalid(INVALID_ADDRESS_2, 'Not a valid Bech32 or Base58 encoding') + node = self.nodes[0] + + # Missing arg returns the help text + assert_raises_rpc_error(-1, "Return information about the given bitcoin address.", node.validateaddress) + # Explicit None is not allowed for required parameters + assert_raises_rpc_error(-3, "JSON value of type null is not of expected type string", node.validateaddress, None) + def test_getaddressinfo(self): node = self.nodes[0] assert_raises_rpc_error(-5, "Invalid Bech32 address data size", node.getaddressinfo, BECH32_INVALID_SIZE) - assert_raises_rpc_error(-5, "Not a valid Bech32 or Base58 encoding", node.getaddressinfo, BECH32_INVALID_PREFIX) - assert_raises_rpc_error(-5, "Invalid prefix for Base58-encoded address", node.getaddressinfo, BASE58_INVALID_PREFIX) - assert_raises_rpc_error(-5, "Not a valid Bech32 or Base58 encoding", node.getaddressinfo, INVALID_ADDRESS) def run_test(self): From fa95f2033a26fb18914c2aa5e5e18650d32e6e4b Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 11 Jan 2023 17:52:47 +0100 Subject: [PATCH 2/2] doc: Fix incorrect sendmany RPC doc This enables the type check and fixes the wrong docs. Otherwise the enabled check would lead to test errors, such as: > "wallet_labels.py", line 96, in run_test > node.sendmany( > > test_framework.authproxy.JSONRPCException: > JSON value of type null is not of expected type string (-3) --- src/wallet/rpc/spend.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpc/spend.cpp b/src/wallet/rpc/spend.cpp index 74f11a71b7a..f7fd6e479f8 100644 --- a/src/wallet/rpc/spend.cpp +++ b/src/wallet/rpc/spend.cpp @@ -314,12 +314,11 @@ RPCHelpMan sendtoaddress() RPCHelpMan sendmany() { return RPCHelpMan{"sendmany", - "\nSend multiple times. Amounts are double-precision floating point numbers." + + "Send multiple times. Amounts are double-precision floating point numbers." + HELP_REQUIRING_PASSPHRASE, { - {"dummy", RPCArg::Type::STR, RPCArg::Optional::NO, "Must be set to \"\" for backwards compatibility.", + {"dummy", RPCArg::Type::STR, RPCArg::Default{"\"\""}, "Must be set to \"\" for backwards compatibility.", RPCArgOptions{ - .skip_type_check = true, .oneline_description = "\"\"", }}, {"amounts", RPCArg::Type::OBJ_USER_KEYS, RPCArg::Optional::NO, "The addresses and amounts",