Skip to content

Commit be0ddb4

Browse files
committed
test: add tests for -mnemonicbits
1 parent b0731e4 commit be0ddb4

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@
213213
'wallet_import_rescan.py',
214214
'wallet_import_with_label.py',
215215
'wallet_upgradewallet.py',
216+
'wallet_mnemonicbits.py',
216217
'rpc_bind.py --ipv4',
217218
'rpc_bind.py --ipv6',
218219
'rpc_bind.py --nonloopback',
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2023 The Dash Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
"""Test -mnemonicbits wallet option."""
6+
7+
from test_framework.test_framework import BitcoinTestFramework
8+
from test_framework.util import (
9+
assert_equal,
10+
)
11+
12+
class WalletMnemonicbitsTest(BitcoinTestFramework):
13+
def set_test_params(self):
14+
self.setup_clean_chain = True
15+
self.num_nodes = 1
16+
self.extra_args = [['-usehd=1']]
17+
18+
def skip_test_if_missing_module(self):
19+
self.skip_if_no_wallet()
20+
21+
def run_test(self):
22+
self.log.info("Test -mnemonicbits")
23+
24+
self.log.info("Invalid -mnemonicbits should rise an error")
25+
self.stop_node(0)
26+
self.nodes[0].assert_start_raises_init_error(self.extra_args[0] + ['-mnemonicbits=123'], "Error: Invalid -mnemonicbits")
27+
self.start_node(0)
28+
assert_equal(len(self.nodes[0].dumphdinfo()["mnemonic"].split()), 12) # 12 words by default
29+
30+
self.log.info("Can have multiple wallets with different mnemonic length loaded at the same time")
31+
self.restart_node(0, extra_args=self.extra_args[0] + ["-mnemonicbits=192"])
32+
self.nodes[0].createwallet("wallet_192")
33+
self.restart_node(0, extra_args=self.extra_args[0] + ["-mnemonicbits=256"])
34+
self.nodes[0].loadwallet("wallet_192")
35+
self.nodes[0].createwallet("wallet_256", False, True) # blank
36+
self.nodes[0].get_wallet_rpc("wallet_256").upgradetohd()
37+
assert_equal(len(self.nodes[0].get_wallet_rpc(self.default_wallet_name).dumphdinfo()["mnemonic"].split()), 12) # 12 words by default
38+
assert_equal(len(self.nodes[0].get_wallet_rpc("wallet_192").dumphdinfo()["mnemonic"].split()), 18) # 18 words
39+
assert_equal(len(self.nodes[0].get_wallet_rpc("wallet_256").dumphdinfo()["mnemonic"].split()), 24) # 24 words
40+
41+
42+
if __name__ == '__main__':
43+
WalletMnemonicbitsTest().main ()

0 commit comments

Comments
 (0)