Bitcoin Core 32.99.0
P2P Digital Currency
Classes | Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
wallet::FaultInjectingDatabase Class Reference

A SQLite wallet database that can fail selected operations for testing. More...

#include <util.h>

Inheritance diagram for wallet::FaultInjectingDatabase:
[legend]
Collaboration diagram for wallet::FaultInjectingDatabase:
[legend]

Classes

struct  Batch
 
struct  Failure
 

Public Member Functions

void FailNextWrite (std::string record_type, size_t match_skip_count=0)
 
void FailNextErase (std::string record_type)
 
void FailNextCommit ()
 
std::optional< SerializeDataGetRecordValue (const std::string &record_type)
 
bool HasRecordType (const std::string &record_type)
 
std::unique_ptr< DatabaseBatchMakeBatch () override
 Make a SQLiteBatch connected to this database. More...
 
- Public Member Functions inherited from wallet::MockableSQLiteDatabase
 MockableSQLiteDatabase ()
 
bool Backup (const std::string &strDest) const override
 Back up the entire database to a file. More...
 
std::string Filename () override
 Return path to main database file for logs and error messages. More...
 
std::string Format () override
 
std::unique_ptr< DatabaseBatchMakeBatch () override
 Make a SQLiteBatch connected to this database. More...
 
- Public Member Functions inherited from wallet::InMemoryWalletDatabase
 InMemoryWalletDatabase ()
 
std::vector< fs::pathFiles () override
 Return paths to all database created files. More...
 
- Public Member Functions inherited from wallet::SQLiteDatabase
 SQLiteDatabase ()=delete
 
 SQLiteDatabase (const fs::path &dir_path, const fs::path &file_path, const DatabaseOptions &options)
 Create DB handle to real database. More...
 
 ~SQLiteDatabase ()
 
bool Verify (bilingual_str &error)
 
void Open () override
 Open the database if it is not already opened. More...
 
void Close () override
 Close the database. More...
 
bool Rewrite () override
 Rewrite the entire database on disk. More...
 
bool Backup (const std::string &dest) const override
 Back up the entire database to a file. More...
 
std::string Filename () override
 Return path to main database file for logs and error messages. More...
 
std::vector< fs::pathFiles () override
 Return paths to all database created files. More...
 
std::string Format () override
 
std::unique_ptr< DatabaseBatchMakeBatch () override
 Make a SQLiteBatch connected to this database. More...
 
bool HasActiveTxn ()
 Return true if there is an on-going txn in this connection. More...
 
- Public Member Functions inherited from wallet::WalletDatabase
 WalletDatabase ()=default
 Create dummy DB handle. More...
 
virtual ~WalletDatabase ()=default
 
virtual void Open ()=0
 Open the database if it is not already opened. More...
 
virtual bool Rewrite ()=0
 Rewrite the entire database on disk. More...
 
virtual bool Backup (const std::string &strDest) const =0
 Back up the entire database to a file. More...
 
virtual void Close ()=0
 Flush to the database file and close the database. More...
 
virtual std::string Filename ()=0
 Return path to main database file for logs and error messages. More...
 
virtual std::vector< fs::pathFiles ()=0
 Return paths to all database created files. More...
 
virtual std::string Format ()=0
 
virtual std::unique_ptr< DatabaseBatchMakeBatch ()=0
 Make a DatabaseBatch connected to this database. More...
 

Static Private Member Functions

static bool ShouldFail (std::optional< Failure > &failure, const DataStream &key)
 

Private Attributes

std::optional< Failurem_fail_write
 
std::optional< Failurem_fail_erase
 
bool m_fail_commit {false}
 

Additional Inherited Members

- Public Attributes inherited from wallet::SQLiteDatabase
std::binary_semaphore m_write_semaphore
 
sqlite3 * m_db {nullptr}
 
bool m_use_unsafe_sync
 
- Protected Member Functions inherited from wallet::SQLiteDatabase
 SQLiteDatabase (const fs::path &dir_path, const fs::path &file_path, const DatabaseOptions &options, int additional_flags)
 

Detailed Description

A SQLite wallet database that can fail selected operations for testing.

Definition at line 76 of file util.h.

Member Function Documentation

◆ FailNextCommit()

void wallet::FaultInjectingDatabase::FailNextCommit ( )
inline

Definition at line 84 of file util.h.

Here is the caller graph for this function:

◆ FailNextErase()

void wallet::FaultInjectingDatabase::FailNextErase ( std::string  record_type)
inline

Definition at line 83 of file util.h.

Here is the caller graph for this function:

◆ FailNextWrite()

void wallet::FaultInjectingDatabase::FailNextWrite ( std::string  record_type,
size_t  match_skip_count = 0 
)
inline

Definition at line 79 of file util.h.

Here is the caller graph for this function:

◆ GetRecordValue()

std::optional< SerializeData > wallet::FaultInjectingDatabase::GetRecordValue ( const std::string &  record_type)
inline

Definition at line 86 of file util.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasRecordType()

bool wallet::FaultInjectingDatabase::HasRecordType ( const std::string &  record_type)
inline

Definition at line 98 of file util.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeBatch()

std::unique_ptr< DatabaseBatch > wallet::FaultInjectingDatabase::MakeBatch ( )
inlineoverridevirtual

Make a SQLiteBatch connected to this database.

Reimplemented from wallet::MockableSQLiteDatabase.

Definition at line 100 of file util.h.

Here is the caller graph for this function:

◆ ShouldFail()

static bool wallet::FaultInjectingDatabase::ShouldFail ( std::optional< Failure > &  failure,
const DataStream key 
)
inlinestaticprivate

Definition at line 108 of file util.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_fail_commit

bool wallet::FaultInjectingDatabase::m_fail_commit {false}
private

Definition at line 148 of file util.h.

◆ m_fail_erase

std::optional<Failure> wallet::FaultInjectingDatabase::m_fail_erase
private

Definition at line 147 of file util.h.

◆ m_fail_write

std::optional<Failure> wallet::FaultInjectingDatabase::m_fail_write
private

Definition at line 146 of file util.h.


The documentation for this class was generated from the following file: