test: migration, avoid backup name mismatch in default_wallet_failure
The test calls migrate_and_get_rpc(), which sets mock time internally. The caller caches a mock time value and later relies on it to predict the backup filename, so setting the mock time again could cause a naming mismatch. Fix this by calling the migration RPC directly. Since the test expects the migration to fail, migrate_and_get_rpc() is unnecessary here.
This commit is contained in:
1 file changed
+3
-1
@@ -711,6 +711,7 @@ class WalletMigrationTest(BitcoinTestFramework):
|
|||||||
master_wallet = self.master_node.get_wallet_rpc(self.default_wallet_name)
|
master_wallet = self.master_node.get_wallet_rpc(self.default_wallet_name)
|
||||||
wallet = self.create_legacy_wallet("", blank=True)
|
wallet = self.create_legacy_wallet("", blank=True)
|
||||||
wallet.importaddress(master_wallet.getnewaddress(address_type="legacy"))
|
wallet.importaddress(master_wallet.getnewaddress(address_type="legacy"))
|
||||||
|
wallet.unloadwallet()
|
||||||
|
|
||||||
# Create wallet directory with the watch-only name and a wallet file.
|
# Create wallet directory with the watch-only name and a wallet file.
|
||||||
# Because the wallet dir exists, this will cause migration to fail.
|
# Because the wallet dir exists, this will cause migration to fail.
|
||||||
@@ -720,7 +721,8 @@ class WalletMigrationTest(BitcoinTestFramework):
|
|||||||
|
|
||||||
mocked_time = int(time.time())
|
mocked_time = int(time.time())
|
||||||
self.master_node.setmocktime(mocked_time)
|
self.master_node.setmocktime(mocked_time)
|
||||||
assert_raises_rpc_error(-4, "Failed to create database", self.migrate_and_get_rpc, "")
|
shutil.copyfile(self.old_node.wallets_path / "wallet.dat", self.master_node.wallets_path / "wallet.dat")
|
||||||
|
assert_raises_rpc_error(-4, "Failed to create database", self.master_node.migratewallet, wallet_name="")
|
||||||
self.master_node.setmocktime(0)
|
self.master_node.setmocktime(0)
|
||||||
|
|
||||||
# Verify the /wallets/ path exists
|
# Verify the /wallets/ path exists
|
||||||
|
|||||||
Reference in new issue
Block a user