Bitcoin Core  24.99.0
P2P Digital Currency
Classes | Typedefs | Functions | Variables
coins_tests.cpp File Reference
#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
 
static const COutPoint OUTPOINT
 
static const CAmount SPENT = -1
 
static const CAmount ABSENT = -2
 
static const CAmount FAIL = -3
 
static const CAmount VALUE1 = 100
 
static const CAmount VALUE2 = 200
 
static const CAmount VALUE3 = 300
 
static const char DIRTY = CCoinsCacheEntry::DIRTY
 
static const char FRESH = CCoinsCacheEntry::FRESH
 
static const char NO_ENTRY = -1
 
static const auto FLAGS = {char(0), FRESH, DIRTY, char(DIRTY | FRESH)}
 
static const auto CLEAN_FLAGS = {char(0), FRESH}
 
static const auto ABSENT_FLAGS = {NO_ENTRY}
 

Typedef Documentation

◆ UtxoData

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

Definition at line 276 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 1797 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 643 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 765 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 498 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 694 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 814 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 266 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 296 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 630 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 759 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 732 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 681 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 795 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 279 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 592 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 577 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 565 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 117 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 1634 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 609 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 CAmount ABSENT = -2
static

Definition at line 552 of file coins_tests.cpp.

◆ ABSENT_FLAGS

const auto ABSENT_FLAGS = {NO_ENTRY}
static

Definition at line 563 of file coins_tests.cpp.

◆ CLEAN_FLAGS

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

Definition at line 562 of file coins_tests.cpp.

◆ DIRTY

const char DIRTY = CCoinsCacheEntry::DIRTY
static

Definition at line 557 of file coins_tests.cpp.

◆ FAIL

const CAmount FAIL = -3
static

Definition at line 553 of file coins_tests.cpp.

◆ FLAGS

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

Definition at line 561 of file coins_tests.cpp.

◆ FRESH

const char FRESH = CCoinsCacheEntry::FRESH
static

Definition at line 558 of file coins_tests.cpp.

◆ NO_ENTRY

const char NO_ENTRY = -1
static

Definition at line 559 of file coins_tests.cpp.

◆ NUM_SIMULATION_ITERATIONS

const unsigned int NUM_SIMULATION_ITERATIONS = 40000
static

Definition at line 101 of file coins_tests.cpp.

◆ OUTPOINT

const COutPoint OUTPOINT
static

Definition at line 550 of file coins_tests.cpp.

◆ SPENT

const CAmount SPENT = -1
static

Definition at line 551 of file coins_tests.cpp.

◆ utxoData

UtxoData utxoData

Definition at line 277 of file coins_tests.cpp.

◆ VALUE1

const CAmount VALUE1 = 100
static

Definition at line 554 of file coins_tests.cpp.

◆ VALUE2

const CAmount VALUE2 = 200
static

Definition at line 555 of file coins_tests.cpp.

◆ VALUE3

const CAmount VALUE3 = 300
static

Definition at line 556 of file coins_tests.cpp.