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