5#include <chainparams.h>
13#include <boost/test/unit_test.hpp>
41 int64_t max_time = -1;
45 int64_t mtp_time = -1;
49 bool cur_active{
false}, next_active{
false};
52 BOOST_CHECK(chain->findBlock(active[99]->GetBlockHash(),
FoundBlock().inActiveChain(cur_active).nextBlock(
FoundBlock().inActiveChain(next_active).hash(next_hash))));
56 cur_active = next_active =
false;
85 BOOST_CHECK(!chain->findAncestorByHeight(active[10]->GetBlockHash(), 20));
94 BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(),
FoundBlock().height(height)));
96 BOOST_CHECK(!chain->findAncestorByHash(active[10]->GetBlockHash(), active[20]->GetBlockHash()));
103 auto* orig_tip = active.Tip();
104 for (
int i = 0; i < 10; ++i) {
106 m_node.
chainman->ActiveChainstate().InvalidateBlock(state, active.Tip());
109 coinbaseKey.MakeNewKey(
true);
110 for (
int i = 0; i < 20; ++i) {
117 BOOST_CHECK(chain->findCommonAncestor(orig_tip->GetBlockHash(), active.Tip()->GetBlockHash(),
FoundBlock().height(fork_height).hash(fork_hash),
FoundBlock().height(orig_height)));
122 uint256 active_hash, orig_hash;
123 BOOST_CHECK(!chain->findCommonAncestor(active.Tip()->GetBlockHash(), {}, {},
FoundBlock().hash(active_hash), {}));
124 BOOST_CHECK(!chain->findCommonAncestor({}, orig_tip->GetBlockHash(), {}, {},
FoundBlock().hash(orig_hash)));
141 active[5]->nStatus &= ~BLOCK_HAVE_DATA;
147 active[95]->nStatus &= ~BLOCK_HAVE_DATA;
153 active[50]->nStatus &= ~BLOCK_HAVE_DATA;
#define Assert(val)
Identity function.
uint256 GetBlockHash() const
int64_t GetBlockTimeMax() const
An in-memory indexed chain of blocks.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
Helper for findBlock to selectively return pieces of block data.
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()
BOOST_AUTO_TEST_CASE(findBlock)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
std::unique_ptr< ChainstateManager > chainman
std::unique_ptr< interfaces::Chain > chain
#define WITH_LOCK(cs, code)
Run code while locking a mutex.