mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-12 19:20:42 +02:00
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 <matiasfurszyfer@protonmail.com>
This commit is contained in:
parent
06439a14c8
commit
1da11dbc44
@ -3,14 +3,15 @@
|
|||||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or https://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <bench/bench.h>
|
#include <bench/bench.h>
|
||||||
#include <kernel/chain.h>
|
|
||||||
#include <interfaces/chain.h>
|
#include <interfaces/chain.h>
|
||||||
|
#include <interfaces/wallet.h>
|
||||||
|
#include <kernel/chain.h>
|
||||||
#include <node/context.h>
|
#include <node/context.h>
|
||||||
#include <test/util/mining.h>
|
#include <test/util/mining.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <wallet/test/util.h>
|
|
||||||
#include <wallet/context.h>
|
#include <wallet/context.h>
|
||||||
#include <wallet/receive.h>
|
#include <wallet/receive.h>
|
||||||
|
#include <wallet/test/util.h>
|
||||||
#include <wallet/wallet.h>
|
#include <wallet/wallet.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -19,11 +20,8 @@ namespace wallet{
|
|||||||
|
|
||||||
static void WalletMigration(benchmark::Bench& bench)
|
static void WalletMigration(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
const auto test_setup = MakeNoLogFileContext<TestingSetup>();
|
const auto test_setup{MakeNoLogFileContext<TestingSetup>()};
|
||||||
|
const auto loader{MakeWalletLoader(*test_setup->m_node.chain, test_setup->m_args)};
|
||||||
WalletContext context;
|
|
||||||
context.args = &test_setup->m_args;
|
|
||||||
context.chain = test_setup->m_node.chain.get();
|
|
||||||
|
|
||||||
// Number of imported watch only addresses
|
// Number of imported watch only addresses
|
||||||
int NUM_WATCH_ONLY_ADDR = 20;
|
int NUM_WATCH_ONLY_ADDR = 20;
|
||||||
@ -63,12 +61,13 @@ static void WalletMigration(benchmark::Bench& bench)
|
|||||||
batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata());
|
batch.WriteKey(pubkey, key.GetPrivKey(), CKeyMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
bench.epochs(/*numEpochs=*/1).run([&context, &wallet] {
|
bench.epochs(/*numEpochs=*/1)
|
||||||
util::Result<MigrationResult> res = MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", context, /*was_loaded=*/false);
|
.run([&] {
|
||||||
assert(res);
|
auto res{MigrateLegacyToDescriptor(std::move(wallet), /*passphrase=*/"", *loader->context(), /*was_loaded=*/false)};
|
||||||
assert(res->wallet);
|
assert(res);
|
||||||
assert(res->watchonly_wallet);
|
assert(res->wallet);
|
||||||
});
|
assert(res->watchonly_wallet);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK(WalletMigration, benchmark::PriorityLevel::LOW);
|
BENCHMARK(WalletMigration, benchmark::PriorityLevel::LOW);
|
||||||
|
Loading…
Reference in New Issue
Block a user