mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-27 20:49:30 +02:00
rpc, test: Fix error message in unloadwallet
The unloadwallet RPC previously failed with a low-level JSON parsing error when called without any arguments (wallet_name). Although this issue was first identified during review of the original unloadwallet implementation in #13111, it was never addressed. Raise RPC_INVALID_PARAMETER instead describing that either the RPC endpoint or wallet name must be provided. Adding a new functional test for this use case. Refactor migratewallet to use the same logic as the wallet_name argument handling is identical. Co-authored-by: maflcko <maflcko@users.noreply.github.com>
This commit is contained in:
@@ -518,8 +518,8 @@ class WalletMigrationTest(BitcoinTestFramework):
|
||||
def test_nonexistent(self):
|
||||
self.log.info("Check migratewallet errors for nonexistent wallets")
|
||||
default = self.master_node.get_wallet_rpc(self.default_wallet_name)
|
||||
assert_raises_rpc_error(-8, "RPC endpoint wallet and wallet_name parameter specify different wallets", default.migratewallet, "someotherwallet")
|
||||
assert_raises_rpc_error(-8, "Either RPC endpoint wallet or wallet_name parameter must be provided", self.master_node.migratewallet)
|
||||
assert_raises_rpc_error(-8, "The RPC endpoint wallet and the wallet name parameter specify different wallets", default.migratewallet, "someotherwallet")
|
||||
assert_raises_rpc_error(-8, "Either the RPC endpoint wallet or the wallet name parameter must be provided", self.master_node.migratewallet)
|
||||
assert_raises_rpc_error(-4, "Error: Wallet does not exist", self.master_node.migratewallet, "notawallet")
|
||||
|
||||
def test_unloaded_by_path(self):
|
||||
|
@@ -343,10 +343,10 @@ class MultiWalletTest(BitcoinTestFramework):
|
||||
self.log.info("Test dynamic wallet unloading")
|
||||
|
||||
# Test `unloadwallet` errors
|
||||
assert_raises_rpc_error(-3, "JSON value of type null is not of expected type string", self.nodes[0].unloadwallet)
|
||||
assert_raises_rpc_error(-8, "Either the RPC endpoint wallet or the wallet name parameter must be provided", self.nodes[0].unloadwallet)
|
||||
assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", self.nodes[0].unloadwallet, "dummy")
|
||||
assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", node.get_wallet_rpc("dummy").unloadwallet)
|
||||
assert_raises_rpc_error(-8, "RPC endpoint wallet and wallet_name parameter specify different wallets", w1.unloadwallet, "w2"),
|
||||
assert_raises_rpc_error(-8, "The RPC endpoint wallet and the wallet name parameter specify different wallets", w1.unloadwallet, "w2"),
|
||||
|
||||
# Successfully unload the specified wallet name
|
||||
self.nodes[0].unloadwallet("w1")
|
||||
|
Reference in New Issue
Block a user