|
14 | 14 | needs an older patch version.
|
15 | 15 | """
|
16 | 16 |
|
| 17 | +import json |
17 | 18 | import os
|
18 | 19 | import shutil
|
19 | 20 |
|
@@ -161,6 +162,38 @@ def test_v22_inactivehdchain_path(self):
|
161 | 162 | except ImportError:
|
162 | 163 | self.log.warning("sqlite3 module not available, skipping lack of keymeta records check")
|
163 | 164 |
|
| 165 | + def test_ignore_legacy_during_startup(self, legacy_nodes, node_master): |
| 166 | + self.log.info("Test that legacy wallets are ignored during startup on v29+") |
| 167 | + |
| 168 | + legacy_node = legacy_nodes[0] |
| 169 | + wallet_name = f"legacy_up_{legacy_node.version}" |
| 170 | + legacy_node.loadwallet(wallet_name) |
| 171 | + legacy_wallet = legacy_node.get_wallet_rpc(wallet_name) |
| 172 | + |
| 173 | + # Move legacy wallet to latest node |
| 174 | + wallet_path = node_master.wallets_path / wallet_name |
| 175 | + wallet_path.mkdir() |
| 176 | + legacy_wallet.backupwallet(wallet_path / "wallet.dat") |
| 177 | + legacy_wallet.unloadwallet() |
| 178 | + |
| 179 | + # Write wallet so it is automatically loaded during init |
| 180 | + settings_path = node_master.chain_path / "settings.json" |
| 181 | + with settings_path.open("w") as fp: |
| 182 | + json.dump({"wallet": [wallet_name]}, fp) |
| 183 | + |
| 184 | + # Restart latest node and verify that the legacy wallet load is skipped without exiting early during init. |
| 185 | + self.restart_node(node_master.index, extra_args=[]) |
| 186 | + # Ensure we receive the warning message and clear the stderr pipe. |
| 187 | + node_master.stderr.seek(0) |
| 188 | + warning_msg = node_master.stderr.read().decode('utf-8').strip() |
| 189 | + assert "The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC or the GUI option)" in warning_msg |
| 190 | + node_master.stderr.truncate(0), node_master.stderr.seek(0) # reset buffer |
| 191 | + |
| 192 | + # Verify the node is still running (no shutdown occurred during startup) |
| 193 | + node_master.getblockcount() |
| 194 | + # Reset settings for any subsequent test |
| 195 | + os.remove(settings_path) |
| 196 | + |
164 | 197 | def run_test(self):
|
165 | 198 | node_miner = self.nodes[0]
|
166 | 199 | node_master = self.nodes[1]
|
@@ -381,6 +414,7 @@ def run_test(self):
|
381 | 414 | assert_raises_rpc_error(-18, "The wallet appears to be a Legacy wallet, please use the wallet migration tool (migratewallet RPC or the GUI option)", node_master.restorewallet, wallet_name, backup_path)
|
382 | 415 |
|
383 | 416 | self.test_v22_inactivehdchain_path()
|
| 417 | + self.test_ignore_legacy_during_startup(legacy_nodes, node_master) |
384 | 418 |
|
385 | 419 | if __name__ == '__main__':
|
386 | 420 | BackwardsCompatibilityTest(__file__).main()
|
0 commit comments