5 #ifndef BITCOIN_WALLET_TEST_UTIL_H 6 #define BITCOIN_WALLET_TEST_UTIL_H 49 using MockableData = std::map<SerializeData, SerializeData, std::less<>>;
110 bool Backup(
const std::string& strDest)
const override {
return m_pass; }
113 std::string
Filename()
override {
return "mockable"; }
114 std::vector<fs::path>
Files()
override {
return {}; }
115 std::string
Format()
override {
return "mock"; }
122 DescriptorScriptPubKeyMan*
CreateDescriptor(CWallet& keystore,
const std::string& desc_str,
bool success);
125 #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.
~MockableCursor()=default
An in-memory indexed chain of blocks.
static const DatabaseFormat DATABASE_FORMATS[]
std::map< SerializeData, SerializeData, std::less<> > MockableData
bool Rewrite() override
Rewrite the entire database on disk.
MockableCursor(const MockableData &records, bool pass)
MockableData::const_iterator m_cursor
bool TxnCommit() override
std::shared_ptr< CWallet > TestLoadWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context)
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)
std::unique_ptr< DatabaseCursor > GetNewPrefixCursor(std::span< const std::byte > prefix) override
MockableData::const_iterator m_cursor_end
RAII class that provides access to a WalletDatabase.
WalletDatabase()=default
Create dummy DB handle.
std::string Format() override
MockableDatabase(MockableData records={})
std::unique_ptr< DatabaseCursor > GetNewCursor() override
std::shared_ptr< CWallet > TestCreateWallet(std::unique_ptr< WalletDatabase > database, WalletContext &context, uint64_t create_flags)
std::string Filename() override
Return path to main database file for logs and error messages.
wallet::DescriptorScriptPubKeyMan * CreateDescriptor(CWallet &keystore, const std::string &desc_str, const bool success)
Double ended buffer combining vector and stream-like interfaces.
bool EraseKey(DataStream &&key) override
std::unique_ptr< DatabaseBatch > MakeBatch() 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.
~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 HasActiveTxn() override
const std::string ADDRESS_BCRT1_UNSPENDABLE
std::vector< fs::path > Files() override
Return paths to all database created files.
An encapsulated private key.
bool HasKey(DataStream &&key) override
RPCHelpMan getnewaddress()
bool ErasePrefix(std::span< const std::byte > prefix) override
An instance of this class represents one database.