MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / WalletCreate

Function WalletCreate

src/bench/wallet_create.cpp:24–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23namespace wallet {
24static void WalletCreate(benchmark::Bench& bench, bool encrypted)
25{
26 auto test_setup = MakeNoLogFileContext<TestingSetup>();
27 FastRandomContext random;
28
29 WalletContext context;
30 context.args = &test_setup->m_args;
31 context.chain = test_setup->m_node.chain.get();
32
33 DatabaseOptions options;
34 options.require_format = DatabaseFormat::SQLITE;
35 options.require_create = true;
36 options.create_flags = WALLET_FLAG_DESCRIPTORS;
37
38 if (encrypted) {
39 options.create_passphrase = random.rand256().ToString();
40 }
41
42 DatabaseStatus status;
43 bilingual_str error_string;
44 std::vector<bilingual_str> warnings;
45
46 const auto wallet_path = test_setup->m_path_root / "test_wallet";
47 const auto wallet_name = fs::PathToString(wallet_path);
48
49 std::shared_ptr<CWallet> wallet;
50 auto cleanup{[&] {
51 if (!wallet) return;
52 // Release wallet
53 RemoveWallet(context, wallet, /*load_on_start=*/std::nullopt);
54 WaitForDeleteWallet(std::move(wallet));
55 fs::remove(wallet_path / "wallet.dat");
56 fs::remove(wallet_path);
57 }};
58 bench.setup(cleanup).run([&] {
59 wallet = CreateWallet(context, wallet_name, /*load_on_start=*/std::nullopt, options, status, error_string, warnings);
60 assert(status == DatabaseStatus::SUCCESS);
61 assert(wallet != nullptr);
62 });
63 cleanup();
64}
65
66static void WalletCreatePlain(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/false); }
67static void WalletCreateEncrypted(benchmark::Bench& bench) { WalletCreate(bench, /*encrypted=*/true); }

Callers 2

WalletCreatePlainFunction · 0.70
WalletCreateEncryptedFunction · 0.70

Calls 10

PathToStringFunction · 0.85
RemoveWalletFunction · 0.85
WaitForDeleteWalletFunction · 0.85
CreateWalletFunction · 0.85
rand256Method · 0.80
cleanupFunction · 0.50
getMethod · 0.45
ToStringMethod · 0.45
runMethod · 0.45
setupMethod · 0.45

Tested by

no test coverage detected