 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
17 #include <boost/test/unit_test.hpp>
37 coins_view.AddCoin(outp, std::move(newcoin),
false);
44 1 << 23,
true,
false);
123 std::vector<CMutableTransaction> noTxns;
125 CBlock validation_block = this->CreateBlock(noTxns, scriptPubKey, background_cs);
126 auto pblock = std::make_shared<const CBlock>(validation_block);
130 bool newblock =
false;
138 bool accepted = background_cs.AcceptBlock(
139 pblock, state, &pindex,
true,
nullptr, &newblock);
143 bool block_added = background_cs.ActivateBestChain(state, pblock);
BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
Test resizing coins-related CChainState caches during runtime.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
static uint256 InsecureRand256()
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
static void add_coin(const CAmount &nValue, int nInput, std::vector< OutputGroup > &set)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
const Consensus::Params & GetConsensus() const
static uint32_t InsecureRand32()
CChainState & ActiveChainstate() const
The most-work chain.
#define BOOST_FIXTURE_TEST_SUITE(a, b)
BOOST_AUTO_TEST_SUITE_END()
#define Assert(val)
Identity function.
CTxOut out
unspent transaction output
bool IsSnapshotActive() const
std::vector< unsigned char > ToByteVector(const T &in)
uint32_t nHeight
at which height this containing transaction was included in the active block chain
uint256 g_best_block
Used to notify getblocktemplate RPC of new tips.
bool HaveCoinInCache(const COutPoint &outpoint) const
Check if we have the given utxo already loaded in this cache.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
CChainState &InitializeChainstate(CTxMemPool *mempool, const std::optional< uint256 > &snapshot_blockhash=std::nullopt) LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(std::vector< CChainState * GetAll)()
Instantiate a new chainstate and assign it based upon whether it is from a snapshot.
CChainState stores and provides an API to update our local knowledge of the current best chain.
Serialized script, used inside transaction inputs and outputs.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
bool CheckBlock(const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
Functions for validating blocks and updating the block tree.
void assign(size_type n, const T &val)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
void SetBestBlock(const uint256 &hashBlock)
static bool CreateAndActivateUTXOSnapshot(node::NodeContext &node, const fs::path root, F malleation=NoMalleation)
Create and activate a UTXO snapshot, optionally providing a function to malleate the snapshot.
const CChainParams & Params()
Return the currently selected parameters.
std::unique_ptr< ChainstateManager > chainman
void InitCoinsDB(size_t cache_size_bytes, bool in_memory, bool should_wipe, std::string leveldb_name="chainstate")
Initialize the CoinsViews UTXO set database management data structures.
Testing setup that configures a complete environment.
An outpoint - a combination of a transaction hash and an index n into its vout.
BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
Test UpdateTip behavior for both active and background chainstates.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
The block chain is a tree shaped structure starting with the genesis block at the root,...
bool LoadGenesisBlock()
Ensures we have a genesis block in the block tree, possibly writing one to disk.
#define BOOST_CHECK(expr)
#define BOOST_CHECK_EQUAL(v1, v2)
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...