wallet, test: Remove DuplicateMockDatabase
What changed, and why it matters
This commit simply removes an unused test helper function called DuplicateMockDatabase and its declaration. It is a code cleanup change with no effect on the live Bitcoin wallet software users run.
No security action needed; this is a benign test-only cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deletes DuplicateMockDatabase from src/wallet/test/util.cpp and its prototype from src/wallet/test/util.h. The function copied a wallet database by iterating its cursor and writing entries into a new mock SQLite database. The commit message states it is no longer used and that benchmarks now run fine with real databases, so the helper is unnecessary. No runtime code paths are modified.
Changed components
src/wallet/test/util.cppsrc/wallet/test/util.hInspect captured patch +0 / −25
diff --git a/src/wallet/test/util.cpp b/src/wallet/test/util.cpp
index b21c96f1..fda8cb1c 100644
--- a/src/wallet/test/util.cpp
+++ b/src/wallet/test/util.cpp
@@ -7,7 +7,6 @@
#include <chain.h>
#include <key.h>
#include <key_io.h>
-#include <streams.h>
#include <test/util/setup_common.h>
#include <validationinterface.h>
#include <wallet/context.h>
@@ -105,27 +104,6 @@ void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet)
WaitForDeleteWallet(std::move(wallet));
}
-std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database)
-{
- std::unique_ptr<DatabaseBatch> batch_orig = database.MakeBatch();
- std::unique_ptr<DatabaseCursor> cursor_orig = batch_orig->GetNewCursor();
-
- std::unique_ptr<WalletDatabase> new_db = CreateMockableWalletDatabase();
- std::unique_ptr<DatabaseBatch> new_db_batch = new_db->MakeBatch();
- MockableSQLiteBatch* batch_new = dynamic_cast<MockableSQLiteBatch*>(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 fbc5188f..9a407d31 100644
--- a/src/wallet/test/util.h
+++ b/src/wallet/test/util.h
@@ -39,9 +39,6 @@ std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context);
std::shared_ptr<CWallet> TestLoadWallet(std::unique_ptr<WalletDatabase> database, WalletContext& context);
void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet);
-// Creates a copy of the provided database
-std::unique_ptr<WalletDatabase> 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 */
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.