mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-29 23:33:33 +02:00
bench: Utilize setup() in WalletCreate to cleanup previous wallets
The WalletCreate benchmark should only be for creating a wallet and exclude the unloading of the newly created wallet. Instead, unloading can be done in setup() and after the benchmark completes.
This commit is contained in:
@@ -47,17 +47,21 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
|
||||
const auto wallet_path = test_setup->m_path_root / "test_wallet";
|
||||
const auto wallet_name = fs::PathToString(wallet_path);
|
||||
|
||||
bench.run([&] {
|
||||
auto wallet = CreateWallet(context, wallet_name, /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
|
||||
assert(status == DatabaseStatus::SUCCESS);
|
||||
assert(wallet != nullptr);
|
||||
|
||||
std::shared_ptr<CWallet> wallet;
|
||||
auto cleanup{[&] {
|
||||
if (!wallet) return;
|
||||
// Release wallet
|
||||
RemoveWallet(context, wallet, /*load_on_start=*/ std::nullopt);
|
||||
RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt);
|
||||
WaitForDeleteWallet(std::move(wallet));
|
||||
fs::remove(wallet_path / "wallet.dat");
|
||||
fs::remove(wallet_path);
|
||||
}};
|
||||
bench.setup(cleanup).run([&] {
|
||||
wallet = CreateWallet(context, wallet_name, /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
|
||||
assert(status == DatabaseStatus::SUCCESS);
|
||||
assert(wallet != nullptr);
|
||||
});
|
||||
cleanup();
|
||||
}
|
||||
|
||||
static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
|
||||
|
||||
Reference in New Issue
Block a user