5#include <chainparams.h>
14#include <boost/test/unit_test.hpp>
18BOOST_AUTO_TEST_SUITE(coinstatsindex_tests)
23 BOOST_REQUIRE(coin_stats_index.
Init());
28 block_index = m_node.chainman->ActiveChain().Tip();
36 BOOST_CHECK(!coin_stats_index.BlockUntilSyncedToCurrentChain());
38 coin_stats_index.
Sync();
44 genesis_block_index = m_node.chainman->ActiveChain().Genesis();
52 std::vector<CMutableTransaction> noTxns;
53 CreateAndProcessBlock(noTxns, script_pub_key);
56 BOOST_CHECK(coin_stats_index.BlockUntilSyncedToCurrentChain());
61 new_block_index = m_node.chainman->ActiveChain().Tip();
68 coin_stats_index.
Stop();
79 BOOST_REQUIRE(index.
Init());
81 std::shared_ptr<const CBlock> new_block;
85 const CBlock block = this->CreateBlock({}, script_pub_key, chainstate);
87 new_block = std::make_shared<CBlock>(block);
92 BOOST_CHECK(m_node.chainman->AcceptBlock(new_block, state, &new_block_index,
true,
nullptr,
nullptr,
true));
105 BOOST_REQUIRE(index.
Init());
BOOST_FIXTURE_TEST_CASE(util_CheckValue, CheckValueTest)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
void Stop()
Stops the instance from staying in sync with blockchain updates.
bool Init()
Initializes the sync state and registers the instance to the validation interface so that it stays in...
void Sync()
Sync the index with the block index starting from the current best block.
bool StartBackgroundSync()
Starts the initial sync process on a background thread.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const Consensus::Params & GetConsensus() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Serialized script, used inside transaction inputs and outputs.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
bool ActivateBestChain(BlockValidationState &state, std::shared_ptr< const CBlock > pblock=nullptr) LOCKS_EXCLUDED(DisconnectResult DisconnectBlock(const CBlock &block, const CBlockIndex *pindex, CCoinsViewCache &view) EXCLUSIVE_LOCKS_REQUIRED(boo ConnectBlock)(const CBlock &block, BlockValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool fJustCheck=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Find the best known block, and make it the tip of the block chain.
CoinStatsIndex maintains statistics on the UTXO set.
std::optional< kernel::CCoinsStats > LookUpStats(const CBlockIndex &block_index) const
static void BlockConnected(const kernel::ChainstateRole &role, CValidationInterface &obj, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_AUTO_TEST_SUITE_END()
std::unique_ptr< Chain > MakeChain(node::NodeContext &node)
Return implementation of Chain interface.
#define BOOST_CHECK(expr)
std::vector< unsigned char > ToByteVector(const T &in)
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Information about chainstate that notifications are sent from.
bool CheckBlock(const CBlock &block, BlockValidationState &state, const Consensus::Params &consensusParams, bool fCheckPOW, bool fCheckMerkleRoot)
Functions for validating blocks and updating the block tree.