12#include <boost/test/unit_test.hpp>
89 for (
CBlockIndex* it{chain[height]}; it !=
nullptr && it->
nHeight > 0; it = it->pprev) {
139 pindex = pindex->pprev;
146 pindex = pindex->pprev;
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.
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 CheckGetPruneHeight(const node::BlockManager &blockman, const CChain &chain, int height) EXCLUSIVE_LOCKS_REQUIRED(
Prune chain from height down to genesis block and check that GetPruneHeight returns the correct value...
static void RejectDifficultyMismatch(double difficulty, double expected_difficulty)
@ BLOCK_VALID_TRANSACTIONS
Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid,...
@ BLOCK_FAILED_VALID
stage after last reached validness failed
#define Assert(val)
Identity function.
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 WITH_LOCK(cs, code)
Run code while locking a mutex.
#define AssertLockHeld(cs)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.