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.
This commit is contained in:
Ava Chow
2025-04-23 15:02:35 -07:00
parent 6d3a8b195a
commit 7fd3e1cf0c

View File

@@ -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<CScript> scripts_watch_only;
for (int w = 0; w < NUM_WATCH_ONLY_ADDR; ++w) {