Bitcoin Core  22.99.0
P2P Digital Currency
Classes | Typedefs | Functions | Variables
coins_tests.cpp File Reference
#include <attributes.h>
#include <clientversion.h>
#include <coins.h>
#include <script/standard.h>
#include <streams.h>
#include <test/util/setup_common.h>
#include <txdb.h>
#include <uint256.h>
#include <undo.h>
#include <util/strencodings.h>
#include <map>
#include <vector>
#include <boost/test/unit_test.hpp>
Include dependency graph for coins_tests.cpp:

Go to the source code of this file.

Classes

class  SingleEntryCacheTest
 

Typedefs

typedef std::map< COutPoint, std::tuple< CTransaction, CTxUndo, Coin > > UtxoData
 

Functions

int ApplyTxInUndo (Coin &&undo, CCoinsViewCache &view, const COutPoint &out)
 Restore the UTXO in a Coin at a given COutPoint. More...
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
 
void SimulationTest (CCoinsView *base, bool fake_best_block)
 
 BOOST_AUTO_TEST_CASE (coins_cache_simulation_test)
 
UtxoData::iterator FindRandomFrom (const std::set< COutPoint > &utxoSet)
 
 BOOST_AUTO_TEST_CASE (updatecoins_simulation_test)
 
 BOOST_AUTO_TEST_CASE (ccoins_serialization)
 
static void SetCoinsValue (CAmount value, Coin &coin)
 
static size_t InsertCoinsMapEntry (CCoinsMap &map, CAmount value, char flags)
 
void GetCoinsMapEntry (const CCoinsMap &map, CAmount &value, char &flags)
 
void WriteCoinsViewEntry (CCoinsView &view, CAmount value, char flags)
 
static void CheckAccessCoin (CAmount base_value, CAmount cache_value, CAmount expected_value, char cache_flags, char expected_flags)
 
 BOOST_AUTO_TEST_CASE (ccoins_access)
 
static void CheckSpendCoins (CAmount base_value, CAmount cache_value, CAmount expected_value, char cache_flags, char expected_flags)
 
 BOOST_AUTO_TEST_CASE (ccoins_spend)
 
static void CheckAddCoinBase (CAmount base_value, CAmount cache_value, CAmount modify_value, CAmount expected_value, char cache_flags, char expected_flags, bool coinbase)
 
template<typename... Args>
static void CheckAddCoin (Args &&... args)
 
 BOOST_AUTO_TEST_CASE (ccoins_add)
 
void CheckWriteCoins (CAmount parent_value, CAmount child_value, CAmount expected_value, char parent_flags, char child_flags, char expected_flags)
 
 BOOST_AUTO_TEST_CASE (ccoins_write)
 

Variables

static const unsigned int NUM_SIMULATION_ITERATIONS = 40000
 
UtxoData utxoData
 
const static COutPoint OUTPOINT
 
const static CAmount SPENT = -1
 
const static CAmount ABSENT = -2
 
const static CAmount FAIL = -3
 
const static CAmount VALUE1 = 100
 
const static CAmount VALUE2 = 200
 
const static CAmount VALUE3 = 300
 
const static char DIRTY = CCoinsCacheEntry::DIRTY
 
const static char FRESH = CCoinsCacheEntry::FRESH
 
const static char NO_ENTRY = -1
 
const static auto FLAGS = {char(0), FRESH, DIRTY, char(DIRTY | FRESH)}
 
const static auto CLEAN_FLAGS = {char(0), FRESH}
 
const static auto ABSENT_FLAGS = {NO_ENTRY}
 

Typedef Documentation

◆ UtxoData

typedef std::map<COutPoint, std::tuple<CTransaction,CTxUndo,Coin> > UtxoData

Definition at line 277 of file coins_tests.cpp.

Function Documentation

◆ ApplyTxInUndo()

int ApplyTxInUndo ( Coin &&  undo,
CCoinsViewCache view,
const COutPoint out 
)

Restore the UTXO in a Coin at a given COutPoint.

Parameters
undoThe Coin to be restored.
viewThe coins view to which to apply the changes.
outThe out point that corresponds to the tx input.
Returns
A DisconnectResult as an int

Definition at line 1402 of file validation.cpp.

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

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( ccoins_access  )

Definition at line 644 of file coins_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( ccoins_add  )

Definition at line 766 of file coins_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( ccoins_serialization  )

Definition at line 499 of file coins_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( ccoins_spend  )

Definition at line 695 of file coins_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( ccoins_write  )

Definition at line 815 of file coins_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( coins_cache_simulation_test  )

Definition at line 267 of file coins_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( updatecoins_simulation_test  )

Definition at line 297 of file coins_tests.cpp.

Here is the call graph for this function:

◆ CheckAccessCoin()

static void CheckAccessCoin ( CAmount  base_value,
CAmount  cache_value,
CAmount  expected_value,
char  cache_flags,
char  expected_flags 
)
static

Definition at line 631 of file coins_tests.cpp.

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

◆ CheckAddCoin()

template<typename... Args>
static void CheckAddCoin ( Args &&...  args)
static

Definition at line 760 of file coins_tests.cpp.

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

◆ CheckAddCoinBase()

static void CheckAddCoinBase ( CAmount  base_value,
CAmount  cache_value,
CAmount  modify_value,
CAmount  expected_value,
char  cache_flags,
char  expected_flags,
bool  coinbase 
)
static

Definition at line 733 of file coins_tests.cpp.

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

◆ CheckSpendCoins()

static void CheckSpendCoins ( CAmount  base_value,
CAmount  cache_value,
CAmount  expected_value,
char  cache_flags,
char  expected_flags 
)
static

Definition at line 682 of file coins_tests.cpp.

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

◆ CheckWriteCoins()

void CheckWriteCoins ( CAmount  parent_value,
CAmount  child_value,
CAmount  expected_value,
char  parent_flags,
char  child_flags,
char  expected_flags 
)

Definition at line 796 of file coins_tests.cpp.

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

◆ FindRandomFrom()

UtxoData::iterator FindRandomFrom ( const std::set< COutPoint > &  utxoSet)

Definition at line 280 of file coins_tests.cpp.

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

◆ GetCoinsMapEntry()

void GetCoinsMapEntry ( const CCoinsMap map,
CAmount value,
char &  flags 
)

Definition at line 593 of file coins_tests.cpp.

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

◆ InsertCoinsMapEntry()

static size_t InsertCoinsMapEntry ( CCoinsMap map,
CAmount  value,
char  flags 
)
static

Definition at line 578 of file coins_tests.cpp.

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

◆ SetCoinsValue()

static void SetCoinsValue ( CAmount  value,
Coin coin 
)
static

Definition at line 566 of file coins_tests.cpp.

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

◆ SimulationTest()

void SimulationTest ( CCoinsView base,
bool  fake_best_block 
)

Definition at line 118 of file coins_tests.cpp.

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

◆ UpdateCoins()

void UpdateCoins ( const CTransaction tx,
CCoinsViewCache inputs,
CTxUndo txundo,
int  nHeight 
)

Definition at line 1228 of file validation.cpp.

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

◆ WriteCoinsViewEntry()

void WriteCoinsViewEntry ( CCoinsView view,
CAmount  value,
char  flags 
)

Definition at line 610 of file coins_tests.cpp.

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

Variable Documentation

◆ ABSENT

const static CAmount ABSENT = -2
static

Definition at line 553 of file coins_tests.cpp.

◆ ABSENT_FLAGS

const static auto ABSENT_FLAGS = {NO_ENTRY}
static

Definition at line 564 of file coins_tests.cpp.

◆ CLEAN_FLAGS

const static auto CLEAN_FLAGS = {char(0), FRESH}
static

Definition at line 563 of file coins_tests.cpp.

◆ DIRTY

const static char DIRTY = CCoinsCacheEntry::DIRTY
static

Definition at line 558 of file coins_tests.cpp.

◆ FAIL

const static CAmount FAIL = -3
static

Definition at line 554 of file coins_tests.cpp.

◆ FLAGS

const static auto FLAGS = {char(0), FRESH, DIRTY, char(DIRTY | FRESH)}
static

Definition at line 562 of file coins_tests.cpp.

◆ FRESH

const static char FRESH = CCoinsCacheEntry::FRESH
static

Definition at line 559 of file coins_tests.cpp.

◆ NO_ENTRY

const static char NO_ENTRY = -1
static

Definition at line 560 of file coins_tests.cpp.

◆ NUM_SIMULATION_ITERATIONS

const unsigned int NUM_SIMULATION_ITERATIONS = 40000
static

Definition at line 102 of file coins_tests.cpp.

◆ OUTPOINT

const static COutPoint OUTPOINT
static

Definition at line 551 of file coins_tests.cpp.

◆ SPENT

const static CAmount SPENT = -1
static

Definition at line 552 of file coins_tests.cpp.

◆ utxoData

UtxoData utxoData

Definition at line 278 of file coins_tests.cpp.

◆ VALUE1

const static CAmount VALUE1 = 100
static

Definition at line 555 of file coins_tests.cpp.

◆ VALUE2

const static CAmount VALUE2 = 200
static

Definition at line 556 of file coins_tests.cpp.

◆ VALUE3

const static CAmount VALUE3 = 300
static

Definition at line 557 of file coins_tests.cpp.