Skip to content

Commit 0a4db75

Browse files
committed
test: add test for upgradetohd with user specified mnemonic and passphrase
1 parent cfffdc5 commit 0a4db75

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

test/functional/wallet_mnemonicbits.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test -mnemonicbits wallet option."""
66

7+
from test_framework.blocktools import COINBASE_MATURITY
78
from test_framework.test_framework import BitcoinTestFramework
89
from test_framework.util import (
910
assert_equal,
@@ -45,7 +46,6 @@ def run_test(self):
4546

4647
mnemonic_pre = self.get_mnemonic(self.nodes[0])
4748

48-
4949
self.nodes[0].encryptwallet('pass')
5050
self.nodes[0].walletpassphrase('pass', 100)
5151
if self.options.descriptors:
@@ -97,6 +97,35 @@ def run_test(self):
9797
assert_equal(len(self.get_mnemonic(self.nodes[0].get_wallet_rpc("wallet_224")).split()), 21) # 21 words
9898
assert_equal(len(self.get_mnemonic(self.nodes[0].get_wallet_rpc("wallet_256")).split()), 24) # 24 words
9999

100+
self.test_upgradetohd_custom()
101+
102+
def test_upgradetohd_custom(self):
103+
self.log.info("Test upgradetohd with user defined mnemonic")
104+
self.nodes[0].createwallet("w-custom-1a", blank=True)
105+
self.nodes[0].createwallet("w-custom-1b", blank=True)
106+
self.nodes[0].createwallet("w-custom-2", blank=True)
107+
custom_mnemonic = "similar behave slot swim scissors throw planet view ghost laugh drift calm"
108+
# this address belongs to custom mnemonic with no passphrase
109+
custom_address_1 = "yLpq97zZUsFQ2rdMqhcPKkYT36MoPK4Hob"
110+
# this address belongs to custom mnemonic with passphrase "custom-passphrase"
111+
custom_address_2 = "yYBPeZQcqgQHu9dxA5pKBWtYbK2hwfFHxf"
112+
113+
self.nodes[0].get_wallet_rpc('w-custom-1a').upgradetohd(custom_mnemonic)
114+
self.nodes[0].get_wallet_rpc('w-custom-1b').upgradetohd(custom_mnemonic, "")
115+
self.nodes[0].get_wallet_rpc('w-custom-2').upgradetohd(custom_mnemonic, "custom-passphrase")
116+
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
117+
118+
self.nodes[0].get_wallet_rpc(self.default_wallet_name).sendtoaddress(custom_address_1, 11)
119+
self.nodes[0].get_wallet_rpc(self.default_wallet_name).sendtoaddress(custom_address_2, 12)
120+
self.generate(self.nodes[0], 1)
121+
self.restart_node(0)
122+
self.nodes[0].loadwallet('w-custom-1a')
123+
self.nodes[0].loadwallet('w-custom-1b')
124+
self.nodes[0].loadwallet('w-custom-2')
125+
assert_equal(11, self.nodes[0].get_wallet_rpc('w-custom-1a').getbalance())
126+
assert_equal(11, self.nodes[0].get_wallet_rpc('w-custom-1b').getbalance())
127+
assert_equal(12, self.nodes[0].get_wallet_rpc('w-custom-2').getbalance())
128+
100129

101130
if __name__ == '__main__':
102131
WalletMnemonicbitsTest().main ()

test/functional/wallet_upgradetohd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"""
66
wallet_upgradetohd.py
77
8-
Test upgrade to a Hierarchical Deterministic wallet via upgradetohd rpc
8+
Test upgrade to a Hierarchical Deterministic wallet via upgradetohd rpc for legacy wallets
9+
For tests of upgradetohd for descriptor wallets see wallet_mnemonicbits.py
910
"""
1011

1112
import shutil

0 commit comments

Comments
 (0)