From 1d1ae6f0c4f2f60f5ceb2d60e8a52662e542e21d Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 6 Apr 2026 15:04:00 -0700 Subject: [PATCH] wallet, test: Remove DuplicateMockDatabase DuplicateMockDatabase is no longer used. Furthermore, as SQLite gets used more as a database and less as a key value store, this function gets more complicated and more bug prone. As the benchmarks now run equivalently quickly with a real database, retaining this duplication function is no longer necessary. --- src/wallet/test/util.cpp | 22 ---------------------- src/wallet/test/util.h | 3 --- 2 files changed, 25 deletions(-) diff --git a/src/wallet/test/util.cpp b/src/wallet/test/util.cpp index b21c96f17ab..fda8cb1c3a9 100644 --- a/src/wallet/test/util.cpp +++ b/src/wallet/test/util.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -105,27 +104,6 @@ void TestUnloadWallet(std::shared_ptr&& wallet) WaitForDeleteWallet(std::move(wallet)); } -std::unique_ptr DuplicateMockDatabase(WalletDatabase& database) -{ - std::unique_ptr batch_orig = database.MakeBatch(); - std::unique_ptr cursor_orig = batch_orig->GetNewCursor(); - - std::unique_ptr new_db = CreateMockableWalletDatabase(); - std::unique_ptr new_db_batch = new_db->MakeBatch(); - MockableSQLiteBatch* batch_new = dynamic_cast(new_db_batch.get()); - Assert(batch_new); - - while (true) { - DataStream key, value; - DatabaseCursor::Status status = cursor_orig->Next(key, value); - Assert(status != DatabaseCursor::Status::FAIL); - if (status != DatabaseCursor::Status::MORE) break; - batch_new->WriteKey(std::move(key), std::move(value)); - } - - return new_db; -} - std::string getnewaddress(CWallet& w) { constexpr auto output_type = OutputType::BECH32; diff --git a/src/wallet/test/util.h b/src/wallet/test/util.h index fbc5188fc14..9a407d31025 100644 --- a/src/wallet/test/util.h +++ b/src/wallet/test/util.h @@ -39,9 +39,6 @@ std::shared_ptr TestLoadWallet(WalletContext& context); std::shared_ptr TestLoadWallet(std::unique_ptr database, WalletContext& context); void TestUnloadWallet(std::shared_ptr&& wallet); -// Creates a copy of the provided database -std::unique_ptr DuplicateMockDatabase(WalletDatabase& database); - /** Returns a new encoded destination from the wallet (hardcoded to BECH32) */ std::string getnewaddress(CWallet& w); /** Returns a new destination, of an specific type, from the wallet */