From 7fd3e1cf0c88553e0722048ce488f265883558e7 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Wed, 23 Apr 2025 15:02:35 -0700 Subject: [PATCH] wallet, bench: Write a bestblock record in WalletMigration Migrating a wallet requires having a bestblock record. This is always the case in normal operation as such a record is always written on wallet loading if it didn't already exist. However, within the unit tests and benchmarks, this is not guaranteed. Since migration requires the record, WalletMigration needs to also add this record before the benchmark. --- src/bench/wallet_migration.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bench/wallet_migration.cpp b/src/bench/wallet_migration.cpp index b5e512f369..a172ec4483 100644 --- a/src/bench/wallet_migration.cpp +++ b/src/bench/wallet_migration.cpp @@ -32,6 +32,10 @@ static void WalletMigration(benchmark::Bench& bench) LegacyDataSPKM* legacy_spkm = wallet->GetOrCreateLegacyDataSPKM(); WalletBatch batch{wallet->GetDatabase()}; + // Write a best block record as migration expects one to exist + CBlockLocator loc; + batch.WriteBestBlock(loc); + // Add watch-only addresses std::vector scripts_watch_only; for (int w = 0; w < NUM_WATCH_ONLY_ADDR; ++w) {