|
10 | 10 | assert_equal, |
11 | 11 | ) |
12 | 12 |
|
| 13 | +custom_mnemonic = "similar behave slot swim scissors throw planet view ghost laugh drift calm" |
| 14 | +# this address belongs to custom mnemonic with no passphrase |
| 15 | +custom_address_1 = "yLpq97zZUsFQ2rdMqhcPKkYT36MoPK4Hob" |
| 16 | +# this address belongs to custom mnemonic with passphrase "custom-passphrase" |
| 17 | +custom_address_2 = "yYBPeZQcqgQHu9dxA5pKBWtYbK2hwfFHxf" |
| 18 | + |
| 19 | + |
13 | 20 | class WalletMnemonicbitsTest(BitcoinTestFramework): |
14 | 21 | def set_test_params(self): |
15 | 22 | self.setup_clean_chain = True |
@@ -97,35 +104,55 @@ def run_test(self): |
97 | 104 | assert_equal(len(self.get_mnemonic(self.nodes[0].get_wallet_rpc("wallet_224")).split()), 21) # 21 words |
98 | 105 | assert_equal(len(self.get_mnemonic(self.nodes[0].get_wallet_rpc("wallet_256")).split()), 24) # 24 words |
99 | 106 |
|
100 | | - self.test_upgradetohd_custom() |
101 | 107 |
|
102 | | - def test_upgradetohd_custom(self): |
| 108 | + self.generate(self.nodes[0], COINBASE_MATURITY + 1) |
| 109 | + |
| 110 | + self.nodes[0].get_wallet_rpc(self.default_wallet_name).sendtoaddress(custom_address_1, 11) |
| 111 | + self.nodes[0].get_wallet_rpc(self.default_wallet_name).sendtoaddress(custom_address_2, 12) |
| 112 | + self.generate(self.nodes[0], 1) |
| 113 | + |
| 114 | + |
103 | 115 | self.log.info("Test upgradetohd with user defined mnemonic") |
104 | | - wname_1a = "w-custom-1a" |
105 | | - wname_1b = "w-custom-1b" |
106 | | - wname_2 = "w-custom-2" |
| 116 | + self.test_upgradetohd_custom(False, False) |
107 | 117 |
|
| 118 | + self.log.info("Test upgradetohd with user defined mnemonic, encrypt wallet after creation") |
| 119 | + self.test_upgradetohd_custom(True, False) |
| 120 | + |
| 121 | + self.log.info("Test upgradetohd with user defined mnemonic, encrypt wallet after upgradetohd") |
| 122 | + self.test_upgradetohd_custom(False, True) |
| 123 | + |
| 124 | + def test_upgradetohd_custom(self, to_encrypt_1, to_encrypt_2): |
| 125 | + wname_1a = f"w-custom-1a-{to_encrypt_1}-{to_encrypt_2}" |
| 126 | + wname_1b = f"w-custom-1b-{to_encrypt_1}-{to_encrypt_2}" |
| 127 | + wname_2 = f"w-custom-2-{to_encrypt_1}-{to_encrypt_2}" |
108 | 128 | wnames = [wname_1a, wname_1b, wname_2] |
| 129 | + |
109 | 130 | for wname in wnames: |
110 | 131 | self.nodes[0].createwallet(wname, blank=True) |
| 132 | + if to_encrypt_1: |
| 133 | + self.nodes[0].get_wallet_rpc(wname).encryptwallet("123") |
| 134 | + self.nodes[0].get_wallet_rpc(wname).walletpassphrase("123", 100) |
| 135 | + |
| 136 | + if to_encrypt_1: |
| 137 | + self.nodes[0].get_wallet_rpc(wname_1a).upgradetohd(custom_mnemonic, "", "123") |
| 138 | + self.nodes[0].get_wallet_rpc(wname_1b).upgradetohd(custom_mnemonic, "", "123") |
| 139 | + self.nodes[0].get_wallet_rpc(wname_2).upgradetohd(custom_mnemonic, "custom-passphrase", "123") |
| 140 | + else: |
| 141 | + self.nodes[0].get_wallet_rpc(wname_1a).upgradetohd(custom_mnemonic) |
| 142 | + self.nodes[0].get_wallet_rpc(wname_1b).upgradetohd(custom_mnemonic, "") |
| 143 | + self.nodes[0].get_wallet_rpc(wname_2).upgradetohd(custom_mnemonic, "custom-passphrase") |
111 | 144 |
|
112 | | - custom_mnemonic = "similar behave slot swim scissors throw planet view ghost laugh drift calm" |
113 | | - # this address belongs to custom mnemonic with no passphrase |
114 | | - custom_address_1 = "yLpq97zZUsFQ2rdMqhcPKkYT36MoPK4Hob" |
115 | | - # this address belongs to custom mnemonic with passphrase "custom-passphrase" |
116 | | - custom_address_2 = "yYBPeZQcqgQHu9dxA5pKBWtYbK2hwfFHxf" |
117 | 145 |
|
118 | | - self.nodes[0].get_wallet_rpc(wname_1a).upgradetohd(custom_mnemonic) |
119 | | - self.nodes[0].get_wallet_rpc(wname_1b).upgradetohd(custom_mnemonic, "") |
120 | | - self.nodes[0].get_wallet_rpc(wname_2).upgradetohd(custom_mnemonic, "custom-passphrase") |
121 | | - self.generate(self.nodes[0], COINBASE_MATURITY + 1) |
| 146 | + if to_encrypt_2: |
| 147 | + for wname in wnames: |
| 148 | + self.nodes[0].get_wallet_rpc(wname).encryptwallet("123") |
| 149 | + self.nodes[0].get_wallet_rpc(wname).walletpassphrase("123", 100) |
122 | 150 |
|
123 | | - self.nodes[0].get_wallet_rpc(self.default_wallet_name).sendtoaddress(custom_address_1, 11) |
124 | | - self.nodes[0].get_wallet_rpc(self.default_wallet_name).sendtoaddress(custom_address_2, 12) |
125 | | - self.generate(self.nodes[0], 1) |
126 | 151 | self.restart_node(0) |
127 | 152 | for wname in wnames: |
128 | 153 | self.nodes[0].loadwallet(wname) |
| 154 | + if to_encrypt_1 or to_encrypt_2: |
| 155 | + self.nodes[0].get_wallet_rpc(wname).walletpassphrase("123", 100) |
129 | 156 |
|
130 | 157 | assert_equal(11, self.nodes[0].get_wallet_rpc(wname_1a).getbalance()) |
131 | 158 | assert_equal(11, self.nodes[0].get_wallet_rpc(wname_1b).getbalance()) |
|
0 commit comments