5#ifndef BITCOIN_WALLET_TEST_UTIL_H
6#define BITCOIN_WALLET_TEST_UTIL_H
8#include <bitcoin-build-config.h>
53using MockableData = std::map<SerializeData, SerializeData, std::less<>>;
117 bool Backup(
const std::string& strDest)
const override {
return m_pass; }
124 std::string
Filename()
override {
return "mockable"; }
125 std::string
Format()
override {
return "mock"; }
126 std::unique_ptr<DatabaseBatch>
MakeBatch(
bool flush_on_close =
true)
override {
return std::make_unique<MockableBatch>(
m_records,
m_pass); }
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
An in-memory indexed chain of blocks.
An encapsulated private key.
Double ended buffer combining vector and stream-like interfaces.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
RAII class that provides access to a WalletDatabase.
bool ReadKey(DataStream &&key, DataStream &value) override
std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(Span< const std::byte > prefix) override
std::unique_ptr< DatabaseCursor > GetNewCursor() override
bool HasActiveTxn() override
bool EraseKey(DataStream &&key) override
bool TxnCommit() override
bool HasKey(DataStream &&key) override
bool ErasePrefix(Span< const std::byte > prefix) override
MockableBatch(MockableData &records, bool pass)
bool WriteKey(DataStream &&key, DataStream &&value, bool overwrite=true) override
MockableCursor(const MockableData &records, bool pass)
MockableData::const_iterator m_cursor_end
MockableData::const_iterator m_cursor
Status Next(DataStream &key, DataStream &value) override
~MockableCursor()=default
A WalletDatabase whose contents and return values can be modified as needed for testing.
MockableDatabase(MockableData records={})
void Open() override
Open the database if it is not already opened.
bool Rewrite(const char *pszSkip=nullptr) override
Rewrite the entire database on disk, with the exception of key pszSkip if non-zero.
bool Backup(const std::string &strDest) const override
Back up the entire database to a file.
std::unique_ptr< DatabaseBatch > MakeBatch(bool flush_on_close=true) override
Make a DatabaseBatch connected to this database.
void Close() override
Flush to the database file and close the database.
std::string Format() override
std::string Filename() override
Return path to main database file for logs and error messages.
~MockableDatabase()=default
void IncrementUpdateCounter() override
void RemoveRef() override
Indicate that database user has stopped using the database and that it could be flushed or closed.
void AddRef() override
Indicate the a new database user has began using the database.
void ReloadDbEnv() override
bool PeriodicFlush() override
void Flush() override
Make sure all changes are flushed to database file.
An instance of this class represents one database.
WalletDatabase()
Create dummy DB handle.
const std::string ADDRESS_BCRT1_UNSPENDABLE
std::shared_ptr< CWallet > TestLoadWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context, uint64_t create_flags)
static const DatabaseFormat DATABASE_FORMATS[]
std::unique_ptr< CWallet > CreateSyncedWallet(interfaces::Chain &chain, CChain &cchain, const CKey &key)
void TestUnloadWallet(std::shared_ptr< CWallet > &&wallet)
MockableDatabase & GetMockableDatabase(CWallet &wallet)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
std::unique_ptr< WalletDatabase > DuplicateMockDatabase(WalletDatabase &database)
RPCHelpMan getnewaddress()
std::map< SerializeData, SerializeData, std::less<> > MockableData
CTxDestination getNewDestination(CWallet &w, OutputType output_type)
Returns a new destination, of an specific type, from the wallet.
WalletContext struct containing references to state shared between CWallet instances,...