Skip to content

Commit 32167e8

Browse files
committed
[wallet] [tests] Add tests for createwallet RPC.
1 parent 9421317 commit 32167e8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/functional/wallet_multiwallet.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,28 @@ def run_test(self):
211211
# Fail to load if wallet file is a symlink
212212
assert_raises_rpc_error(-4, "Wallet file verification failed: Invalid -wallet path 'w8_symlink'", self.nodes[0].loadwallet, 'w8_symlink')
213213

214+
self.log.info("Test dynamic wallet creation.")
215+
216+
# Fail to create a wallet if it already exists.
217+
assert_raises_rpc_error(-4, "Wallet w2 already exists.", self.nodes[0].createwallet, 'w2')
218+
219+
# Successfully create a wallet with a new name
220+
loadwallet_name = self.nodes[0].createwallet('w9')
221+
assert_equal(loadwallet_name['name'], 'w9')
222+
w9 = node.get_wallet_rpc('w9')
223+
assert_equal(w9.getwalletinfo()['walletname'], 'w9')
224+
225+
assert 'w9' in self.nodes[0].listwallets()
226+
227+
# Successfully create a wallet using a full path
228+
new_wallet_dir = os.path.join(self.options.tmpdir, 'new_walletdir')
229+
new_wallet_name = os.path.join(new_wallet_dir, 'w10')
230+
loadwallet_name = self.nodes[0].createwallet(new_wallet_name)
231+
assert_equal(loadwallet_name['name'], new_wallet_name)
232+
w10 = node.get_wallet_rpc(new_wallet_name)
233+
assert_equal(w10.getwalletinfo()['walletname'], new_wallet_name)
234+
235+
assert new_wallet_name in self.nodes[0].listwallets()
236+
214237
if __name__ == '__main__':
215238
MultiWalletTest().main()

0 commit comments

Comments
 (0)