5 #include <chainparams.h>
14 #include <boost/test/unit_test.hpp>
24 const auto timeout = GetTime<std::chrono::seconds>() + 120s;
25 while (!index.BlockUntilSyncedToCurrentChain()) {
26 BOOST_REQUIRE(timeout > GetTime<std::chrono::milliseconds>());
42 BOOST_CHECK(!coin_stats_index.LookUpStats(*block_index));
46 BOOST_CHECK(!coin_stats_index.BlockUntilSyncedToCurrentChain());
48 BOOST_REQUIRE(coin_stats_index.Start());
58 BOOST_CHECK(coin_stats_index.LookUpStats(*genesis_block_index));
61 BOOST_CHECK(coin_stats_index.LookUpStats(*block_index));
64 std::vector<CMutableTransaction> noTxns;
65 CreateAndProcessBlock(noTxns, script_pub_key);
68 BOOST_CHECK(coin_stats_index.BlockUntilSyncedToCurrentChain());
75 BOOST_CHECK(coin_stats_index.LookUpStats(*new_block_index));
88 coin_stats_index.Stop();
99 BOOST_REQUIRE(index.Start());
101 std::shared_ptr<const CBlock> new_block;
105 const CBlock block = this->CreateBlock({}, script_pub_key, chainstate);
107 new_block = std::make_shared<CBlock>(block);
126 BOOST_REQUIRE(index.Start());
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Base class for indices of blockchain data.
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.
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)
Apply the effects of this block (with given index) on the UTXO set represented by coins.
bool ActivateBestChain(BlockValidationState &state, std::shared_ptr< const CBlock > pblock=nullptr) LOCKS_EXCLUDED(bool AcceptBlock(const std::shared_ptr< const CBlock > &pblock, BlockValidationState &state, CBlockIndex **ppindex, bool fRequested, const FlatFilePos *dbp, bool *fNewBlock, bool min_pow_checked) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Find the best known block, and make it the tip of the block chain.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
CoinStatsIndex maintains statistics on the UTXO set.
static void BlockConnected(CValidationInterface &obj, const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex)
BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
static void IndexWaitSynced(BaseIndex &index)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_AUTO_TEST_SUITE(cuckoocache_tests)
Test Suite for CuckooCache.
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.
std::unique_ptr< ChainstateManager > chainman
void UninterruptibleSleep(const std::chrono::microseconds &n)
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 SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...