Skip to content

Commit 4940a20

Browse files
committed
test: Add functional tests for unloadwallet RPC
1 parent 6608c36 commit 4940a20

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/functional/wallet_multiwallet.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,5 +234,26 @@ def run_test(self):
234234

235235
assert new_wallet_name in self.nodes[0].listwallets()
236236

237+
self.log.info("Test dynamic wallet unloading")
238+
239+
# Test `unloadwallet` errors
240+
assert_raises_rpc_error(-1, "JSON value is not a string as expected", self.nodes[0].unloadwallet)
241+
assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", self.nodes[0].unloadwallet, "dummy")
242+
assert_raises_rpc_error(-18, "Requested wallet does not exist or is not loaded", node.get_wallet_rpc("dummy").unloadwallet)
243+
assert_raises_rpc_error(-8, "Cannot unload the requested wallet", w1.unloadwallet, "w2"),
244+
245+
# Successfully unload the specified wallet name
246+
self.nodes[0].unloadwallet("w1")
247+
assert 'w1' not in self.nodes[0].listwallets()
248+
249+
# Successfully unload the wallet referenced by the request endpoint
250+
w2.unloadwallet()
251+
assert 'w2' not in self.nodes[0].listwallets()
252+
253+
# Successfully unload all wallets
254+
for wallet_name in self.nodes[0].listwallets():
255+
self.nodes[0].unloadwallet(wallet_name)
256+
assert_equal(self.nodes[0].listwallets(), [])
257+
237258
if __name__ == '__main__':
238259
MultiWalletTest().main()

0 commit comments

Comments
 (0)