From 7508ac319d992eb0a731a7b2e879bcad5859c3c4 Mon Sep 17 00:00:00 2001 From: Pablo Martin Date: Mon, 13 Jul 2026 00:17:16 -0300 Subject: [PATCH] bench: replace CreateMockableWalletDatabase with MakeInMemoryWalletDatabase Benchmarks don't need mock-specific behaviour (overridden Filename(), Format(), or the exposed batch-level WriteKey()). Replace CreateMockableWalletDatabase() with MakeInMemoryWalletDatabase() across 6 call sites in src/bench/ (5 files), using the same in-memory SQLite path that production code uses. wallet_migration.cpp is excluded: it calls GetOrCreateLegacyDataSPKM() which asserts Format() == "sqlite-mock", a signal used to allow legacy SPKM setup in test/bench contexts. MockableSQLiteDatabase is still correct there. For coin_selection.cpp, which had no other dependencies on wallet/test/util.h, also switch the include to . Follow-up suggested in #35655. --- src/bench/coin_selection.cpp | 4 ++-- src/bench/wallet_balance.cpp | 3 ++- src/bench/wallet_create_tx.cpp | 7 ++++--- src/bench/wallet_encrypt.cpp | 3 ++- src/bench/wallet_ismine.cpp | 3 ++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index 4f203fe8618..5c54cafc547 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -50,7 +50,7 @@ static void addCoin(const CAmount& nValue, std::vector(); - CWallet wallet(test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()); + CWallet wallet(test_setup->m_node.chain.get(), "", MakeInMemoryWalletDatabase()); std::vector> wtxs; LOCK(wallet.cs_wallet); diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp index 958044e2e40..76d0fd39cff 100644 --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ static void WalletBalance(benchmark::Bench& bench, const bool set_dirty, const b // Set clock to genesis block, so the descriptors/keys creation time don't interfere with the blocks scanning process. // The reason is 'generatetoaddress', which creates a chain with deterministic timestamps in the past. FakeNodeClock clock{test_setup->m_node.chainman->GetParams().GenesisBlock().Time()}; - CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()}; + CWallet wallet{test_setup->m_node.chain.get(), "", MakeInMemoryWalletDatabase()}; { LOCK(wallet.cs_wallet); wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS); diff --git a/src/bench/wallet_create_tx.cpp b/src/bench/wallet_create_tx.cpp index 394f21ce187..b0140910696 100644 --- a/src/bench/wallet_create_tx.cpp +++ b/src/bench/wallet_create_tx.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,7 @@ using kernel::ChainstateRole; using wallet::CWallet; -using wallet::CreateMockableWalletDatabase; +using wallet::MakeInMemoryWalletDatabase; using wallet::WALLET_FLAG_DESCRIPTORS; struct TipBlock @@ -120,7 +121,7 @@ static void WalletCreateTx(benchmark::Bench& bench, const OutputType output_type // Set clock to genesis block, so the descriptors/keys creation time don't interfere with the blocks scanning process. FakeNodeClock clock{test_setup->m_node.chainman->GetParams().GenesisBlock().Time()}; - CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()}; + CWallet wallet{test_setup->m_node.chain.get(), "", MakeInMemoryWalletDatabase()}; { LOCK(wallet.cs_wallet); wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS); @@ -175,7 +176,7 @@ static void AvailableCoins(benchmark::Bench& bench, const std::vector(); // Set clock to genesis block, so the descriptors/keys creation time don't interfere with the blocks scanning process. FakeNodeClock clock{test_setup->m_node.chainman->GetParams().GenesisBlock().Time()}; - CWallet wallet{test_setup->m_node.chain.get(), "", CreateMockableWalletDatabase()}; + CWallet wallet{test_setup->m_node.chain.get(), "", MakeInMemoryWalletDatabase()}; { LOCK(wallet.cs_wallet); wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS); diff --git a/src/bench/wallet_encrypt.cpp b/src/bench/wallet_encrypt.cpp index 81e64a282a7..7f6ff3af7a8 100644 --- a/src/bench/wallet_encrypt.cpp +++ b/src/bench/wallet_encrypt.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -64,7 +65,7 @@ static void WalletEncrypt(benchmark::Bench& bench, unsigned int key_count) TestUnloadWallet(std::move(wallet)); } - std::unique_ptr database = CreateMockableWalletDatabase(); + std::unique_ptr database = MakeInMemoryWalletDatabase(); wallet = TestCreateWallet(std::move(database), context, create_flags); { diff --git a/src/bench/wallet_ismine.cpp b/src/bench/wallet_ismine.cpp index 572a2717f22..4b059b347e8 100644 --- a/src/bench/wallet_ismine.cpp +++ b/src/bench/wallet_ismine.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ static void WalletIsMine(benchmark::Bench& bench, int num_combo = 0) // Setup the wallet // Loading the wallet will also create it uint64_t create_flags = WALLET_FLAG_DESCRIPTORS; - auto database = CreateMockableWalletDatabase(); + auto database = MakeInMemoryWalletDatabase(); auto wallet = TestCreateWallet(std::move(database), context, create_flags); // For a descriptor wallet, fill with num_combo combo descriptors with random keys