diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dff87ad238..9d8fdb4a16e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -358,8 +358,7 @@ jobs: ./src/univalue/unitester.exe - name: Run benchmarks - # TODO: Fix the `WalletMigration` benchmark and re-enable it. - run: ./bin/bench_bitcoin.exe -sanity-check -filter='^(?!WalletMigration$).+$' + run: ./bin/bench_bitcoin.exe -sanity-check - name: Adjust paths in test/config.ini shell: pwsh diff --git a/src/bench/wallet_migration.cpp b/src/bench/wallet_migration.cpp index ca28ab04487..afb79d98afb 100644 --- a/src/bench/wallet_migration.cpp +++ b/src/bench/wallet_migration.cpp @@ -3,14 +3,15 @@ // file COPYING or https://www.opensource.org/licenses/mit-license.php. #include -#include #include +#include +#include #include #include #include -#include #include #include +#include #include #include @@ -19,11 +20,8 @@ namespace wallet{ static void WalletMigration(benchmark::Bench& bench) { - const auto test_setup = MakeNoLogFileContext(); - - WalletContext context; - context.args = &test_setup->m_args; - context.chain = test_setup->m_node.chain.get(); + const auto test_setup{MakeNoLogFileContext()}; + const auto loader{MakeWalletLoader(*test_setup->m_node.chain, test_setup->m_args)}; // Number of imported watch only addresses int NUM_WATCH_ONLY_ADDR = 20; @@ -63,12 +61,13 @@ static void WalletMigration(benchmark::Bench& bench) batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata()); } - bench.epochs(/*numEpochs=*/1).run([&context, &wallet] { - util::Result res = MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", context, /*was_loaded=*/false); - assert(res); - assert(res->wallet); - assert(res->watchonly_wallet); - }); + bench.epochs(/*numEpochs=*/1).epochIterations(/*numIters=*/1) // run the migration exactly once + .run([&] { + auto res{MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", *loader->context(), /*was_loaded=*/false)}; + assert(res); + assert(res->wallet); + assert(res->watchonly_wallet); + }); } BENCHMARK(WalletMigration, benchmark::PriorityLevel::LOW);