5#include <chainparams.h>
12#include <boost/test/unit_test.hpp>
40 int64_t max_time = -1;
44 int64_t mtp_time = -1;
48 bool cur_active{
false}, next_active{
false};
51 BOOST_CHECK(chain->findBlock(active[99]->GetBlockHash(),
FoundBlock().inActiveChain(cur_active).nextBlock(
FoundBlock().inActiveChain(next_active).hash(next_hash))));
55 cur_active = next_active =
false;
84 BOOST_CHECK(!chain->findAncestorByHeight(active[10]->GetBlockHash(), 20));
93 BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(),
FoundBlock().height(height)));
95 BOOST_CHECK(!chain->findAncestorByHash(active[10]->GetBlockHash(), active[20]->GetBlockHash()));
102 auto* orig_tip = active.Tip();
103 for (
int i = 0; i < 10; ++i) {
105 m_node.
chainman->ActiveChainstate().InvalidateBlock(state, active.Tip());
108 coinbaseKey.MakeNewKey(
true);
109 for (
int i = 0; i < 20; ++i) {
116 BOOST_CHECK(chain->findCommonAncestor(orig_tip->GetBlockHash(), active.Tip()->GetBlockHash(),
FoundBlock().height(fork_height).hash(fork_hash),
FoundBlock().height(orig_height)));
121 uint256 active_hash, orig_hash;
122 BOOST_CHECK(!chain->findCommonAncestor(active.Tip()->GetBlockHash(), {}, {},
FoundBlock().hash(active_hash), {}));
123 BOOST_CHECK(!chain->findCommonAncestor({}, orig_tip->GetBlockHash(), {}, {},
FoundBlock().hash(orig_hash)));
140 active[5]->nStatus &= ~BLOCK_HAVE_DATA;
146 active[95]->nStatus &= ~BLOCK_HAVE_DATA;
152 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.