nit in 78897500676f7ab1b197da56c0a676efcb49ec41 : I guess there is no real risk in having them public, due to the types involved, but if you wanted to make them protected, it could be done with this diff:
diff --git a/src/wallet/sqlite.h b/src/wallet/sqlite.h
index 57876bd83c..ce703f8f13 100644
--- a/src/wallet/sqlite.h
+++ b/src/wallet/sqlite.h
@@ -75,6 +75,14 @@ private:
void SetupSQLStatements();
bool ExecStatement(sqlite3_stmt* stmt, std::span<const std::byte> blob);
+protected:
+
+ bool ReadKey(DataStream&& key, DataStream& value) override;
+ bool WriteKey(DataStream&& key, DataStream&& value, bool overwrite = true) override;
+ bool EraseKey(DataStream&& key) override;
+ bool HasKey(DataStream&& key) override;
+ bool ErasePrefix(std::span<const std::byte> prefix) override;
+
public:
explicit SQLiteBatch(SQLiteDatabase& database);
~SQLiteBatch() override { Close(); }
@@ -89,14 +97,6 @@ public:
bool TxnCommit() override;
bool TxnAbort() override;
bool HasActiveTxn() override { return m_txn; }
-
- // DO NOT CALL DIRECTLY, use DatabaseBatch::Read, Write, Erase, Exists, and ErasePrefix.
- // These functions are public for testing only.
- bool ReadKey(DataStream&& key, DataStream& value) override;
- bool WriteKey(DataStream&& key, DataStream&& value, bool overwrite = true) override;
- bool EraseKey(DataStream&& key) override;
- bool HasKey(DataStream&& key) override;
- bool ErasePrefix(std::span<const std::byte> prefix) override;
};
/** An instance of this class represents one SQLite3 database.
diff --git a/src/wallet/test/util.cpp b/src/wallet/test/util.cpp
index 5162baed9f..95255b7062 100644
--- a/src/wallet/test/util.cpp
+++ b/src/wallet/test/util.cpp
@@ -79,6 +79,10 @@ void TestUnloadWallet(std::shared_ptr<CWallet>&& wallet)
WaitForDeleteWallet(std::move(wallet));
}
+struct SQLiteBatchTest:public SQLiteBatch{
+using SQLiteBatch::WriteKey;
+};
+
std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database)
{
std::unique_ptr<DatabaseBatch> batch_orig = database.MakeBatch();
@@ -86,7 +90,7 @@ std::unique_ptr<WalletDatabase> DuplicateMockDatabase(WalletDatabase& database)
std::unique_ptr<WalletDatabase> new_db = CreateMockableWalletDatabase();
std::unique_ptr<DatabaseBatch> new_db_batch = new_db->MakeBatch();
- SQLiteBatch* batch_new = dynamic_cast<SQLiteBatch*>(new_db_batch.get());
+ auto* batch_new = dynamic_cast<SQLiteBatchTest*>(new_db_batch.get());
Assert(batch_new);
while (true) {