mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
bench: bugfix, properly release wallet before erasing directory
Since the wallet is appended to the global WalletContext during creation, merely calling 'reset()' on the benchmark shared_pointer is insufficient to destruct the wallet. This no destruction of the wallet results in the db connection remaining open, which was the cause of the 'fs::remove_all()' error in Windows. Co-Authored-By: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
This commit is contained in:
parent
dd42a5ddea
commit
7c8abf3c20
1 changed files with 5 additions and 9 deletions
|
@ -34,14 +34,15 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
|
||||||
bilingual_str error_string;
|
bilingual_str error_string;
|
||||||
std::vector<bilingual_str> warnings;
|
std::vector<bilingual_str> warnings;
|
||||||
|
|
||||||
fs::path wallet_path = test_setup->m_path_root / strprintf("test_wallet_%d", random.rand32()).c_str();
|
auto wallet_path = fs::PathToString(test_setup->m_path_root / "test_wallet");
|
||||||
bench.run([&] {
|
bench.run([&] {
|
||||||
auto wallet = CreateWallet(context, wallet_path.utf8string(), /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
|
auto wallet = CreateWallet(context, wallet_path, /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
|
||||||
assert(status == DatabaseStatus::SUCCESS);
|
assert(status == DatabaseStatus::SUCCESS);
|
||||||
assert(wallet != nullptr);
|
assert(wallet != nullptr);
|
||||||
|
|
||||||
// Cleanup
|
// Release wallet
|
||||||
wallet.reset();
|
RemoveWallet(context, wallet, /*load_on_start=*/ std::nullopt);
|
||||||
|
UnloadWallet(std::move(wallet));
|
||||||
fs::remove_all(wallet_path);
|
fs::remove_all(wallet_path);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -49,14 +50,9 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
|
||||||
static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
|
static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
|
||||||
static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }
|
static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
// TODO: Being built with MSVC, the fs::remove_all() call in
|
|
||||||
// the WalletCreate() fails with the error "The process cannot
|
|
||||||
// access the file because it is being used by another process."
|
|
||||||
#ifdef USE_SQLITE
|
#ifdef USE_SQLITE
|
||||||
BENCHMARK(WalletCreatePlain, benchmark::PriorityLevel::LOW);
|
BENCHMARK(WalletCreatePlain, benchmark::PriorityLevel::LOW);
|
||||||
BENCHMARK(WalletCreateEncrypted, benchmark::PriorityLevel::LOW);
|
BENCHMARK(WalletCreateEncrypted, benchmark::PriorityLevel::LOW);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace wallet
|
} // namespace wallet
|
||||||
|
|
Loading…
Add table
Reference in a new issue