|
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php. |
5 | 5 | """Test -mnemonicbits wallet option.""" |
6 | 6 |
|
| 7 | +from test_framework.blocktools import COINBASE_MATURITY |
7 | 8 | from test_framework.test_framework import BitcoinTestFramework |
8 | 9 | from test_framework.util import ( |
9 | 10 | assert_equal, |
@@ -45,7 +46,6 @@ def run_test(self): |
45 | 46 |
|
46 | 47 | mnemonic_pre = self.get_mnemonic(self.nodes[0]) |
47 | 48 |
|
48 | | - |
49 | 49 | self.nodes[0].encryptwallet('pass') |
50 | 50 | self.nodes[0].walletpassphrase('pass', 100) |
51 | 51 | if self.options.descriptors: |
@@ -97,6 +97,35 @@ def run_test(self): |
97 | 97 | assert_equal(len(self.get_mnemonic(self.nodes[0].get_wallet_rpc("wallet_224")).split()), 21) # 21 words |
98 | 98 | assert_equal(len(self.get_mnemonic(self.nodes[0].get_wallet_rpc("wallet_256")).split()), 24) # 24 words |
99 | 99 |
|
| 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 | + |
100 | 129 |
|
101 | 130 | if __name__ == '__main__': |
102 | 131 | WalletMnemonicbitsTest().main () |
0 commit comments