test: migration, avoid backup name mismatch in default_wallet_failure
What changed, and why it matters
This is a fix to a Bitcoin Core functional test, not to production wallet code. The test was predicting a backup filename based on a cached mock time, but the helper it called also changed mock time internally, which could make the predicted filename wrong and cause the test to fail. The fix calls the migration RPC directly and copies a wallet file explicitly. There is no security issue in the Bitcoin Core software itself.
No security action required. Treat as a normal test reliability improvement.
Security signals we found
No changes to production code
Test-only change in functional test suite
No cryptographic, consensus, or network code modified
Evidence from the diff
Commit cbf0bd35bbf312f3b13d92d281d7112e4b43b9c3 modifies test/functional/wallet_migration.py. The test default_wallet_failure previously used migrate_and_get_rpc(), which internally calls setmocktime(). The test cached a mock time value and later relied on it to derive an expected backup filename, so a second setmocktime() could produce a timestamp mismatch. The patch unloads the wallet, copies wallet.dat explicitly, and invokes migratewallet directly via the RPC. This is a test-only reliability fix; no wallet migration logic in the node is changed.
Changed components
test/functional/wallet_migration.pyInspect captured patch +3 / −1
diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py
index e90c48fa..c6eed10d 100755
--- a/test/functional/wallet_migration.py
+++ b/test/functional/wallet_migration.py
@@ -711,6 +711,7 @@ class WalletMigrationTest(BitcoinTestFramework):
master_wallet = self.master_node.get_wallet_rpc(self.default_wallet_name)
wallet = self.create_legacy_wallet("", blank=True)
wallet.importaddress(master_wallet.getnewaddress(address_type="legacy"))
+ wallet.unloadwallet()
# Create wallet directory with the watch-only name and a wallet file.
# Because the wallet dir exists, this will cause migration to fail.
@@ -720,7 +721,8 @@ class WalletMigrationTest(BitcoinTestFramework):
mocked_time = int(time.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)
# Verify the /wallets/ path exists
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.