Skip to content

Commit 1da11db

Browse files
l0rincfurszy
andcommitted
bench: clean up migrated descriptor wallets via loader teardown
`MigrateLegacyToDescriptor` returns both a spendable descriptor wallet and a watch‑only wallet. If these remain attached, their files stay open and on Windows this can hang CI when removing the test directory. By constructing them via `MakeWalletLoader` (which owns the `WalletContext`), both wallets are automatically unloaded when the loader is destroyed at the end. This ensures no lingering handles or resource leaks when running the benchmark on CI with `-sanity-check`. Co-authored-by: furszy <[email protected]>
1 parent 06439a1 commit 1da11db

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/bench/wallet_migration.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
44

55
#include <bench/bench.h>
6-
#include <kernel/chain.h>
76
#include <interfaces/chain.h>
7+
#include <interfaces/wallet.h>
8+
#include <kernel/chain.h>
89
#include <node/context.h>
910
#include <test/util/mining.h>
1011
#include <test/util/setup_common.h>
11-
#include <wallet/test/util.h>
1212
#include <wallet/context.h>
1313
#include <wallet/receive.h>
14+
#include <wallet/test/util.h>
1415
#include <wallet/wallet.h>
1516

1617
#include <optional>
@@ -19,11 +20,8 @@ namespace wallet{
1920

2021
static void WalletMigration(benchmark::Bench& bench)
2122
{
22-
const auto test_setup = MakeNoLogFileContext<TestingSetup>();
23-
24-
WalletContext context;
25-
context.args = &test_setup->m_args;
26-
context.chain = test_setup->m_node.chain.get();
23+
const auto test_setup{MakeNoLogFileContext<TestingSetup>()};
24+
const auto loader{MakeWalletLoader(*test_setup->m_node.chain, test_setup->m_args)};
2725

2826
// Number of imported watch only addresses
2927
int NUM_WATCH_ONLY_ADDR = 20;
@@ -63,12 +61,13 @@ static void WalletMigration(benchmark::Bench& bench)
6361
batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata());
6462
}
6563

66-
bench.epochs(/*numEpochs=*/1).run([&context, &wallet] {
67-
util::Result<MigrationResult> res = MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", context, /*was_loaded=*/false);
68-
assert(res);
69-
assert(res->wallet);
70-
assert(res->watchonly_wallet);
71-
});
64+
bench.epochs(/*numEpochs=*/1)
65+
.run([&] {
66+
auto res{MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", *loader->context(), /*was_loaded=*/false)};
67+
assert(res);
68+
assert(res->wallet);
69+
assert(res->watchonly_wallet);
70+
});
7271
}
7372

7473
BENCHMARK(WalletMigration, benchmark::PriorityLevel::LOW);

0 commit comments

Comments
 (0)