5#include <boost/test/unit_test.hpp>
23 return std::abs(a - b) < epsilon;
30 block_index->
nTime = 1269211443;
31 block_index->
nBits = nbits;
38 "Difficulty was " +
ToString(difficulty)
39 +
" but was expected to be " +
ToString(expected_difficulty));
89 for (
CBlockIndex* it{chain[height]}; it !=
nullptr && it->
nHeight > 0; it = it->pprev) {
90 it->nStatus &= ~BLOCK_HAVE_DATA;
94 BOOST_REQUIRE(prune_height.has_value());
117 BOOST_CHECK_EQUAL(block_index.m_chain_tx_count, std::numeric_limits<uint64_t>::max());
double GetDifficulty(const CBlockIndex &blockindex)
Get the difficulty of the net wrt to the given block index.
std::optional< int > GetPruneHeight(const BlockManager &blockman, const CChain &chain)
Return height of highest block that has been pruned, or std::nullopt if no blocks have been pruned.
static void CheckGetPruneHeight(node::BlockManager &blockman, CChain &chain, int height) EXCLUSIVE_LOCKS_REQUIRED(
Prune chain from height down to genesis block and check that GetPruneHeight returns the correct value...
BOOST_FIXTURE_TEST_CASE(get_prune_height, TestChain100Setup)
static bool DoubleEquals(double a, double b, double epsilon)
static CBlockIndex * CreateBlockIndexWithNbits(uint32_t nbits)
static void TestDifficulty(uint32_t nbits, double expected_difficulty)
BOOST_AUTO_TEST_CASE(get_difficulty_for_very_low_target)
static void RejectDifficultyMismatch(double difficulty, double expected_difficulty)
The block chain is a tree shaped structure starting with the genesis block at the root,...
uint64_t m_chain_tx_count
(memory only) Number of transactions in the chain up to and including this block.
int nHeight
height of the entry in the chain. The genesis block has height 0
An in-memory indexed chain of blocks.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
std::string ToString(const T &t)
Locale-independent version of std::to_string.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
std::unique_ptr< ChainstateManager > chainman
#define EXCLUSIVE_LOCKS_REQUIRED(...)