12#include <boost/test/unit_test.hpp>
39 int64_t max_time = -1;
43 int64_t mtp_time = -1;
47 bool cur_active{
false}, next_active{
false};
50 BOOST_CHECK(chain->findBlock(active[99]->GetBlockHash(),
FoundBlock().inActiveChain(cur_active).nextBlock(
FoundBlock().inActiveChain(next_active).hash(next_hash))));
54 cur_active = next_active =
false;
81 BOOST_CHECK(!chain->findAncestorByHeight(active[10]->GetBlockHash(), 20));
89 BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), active[10]->GetBlockHash(),
FoundBlock().height(height)));
91 BOOST_CHECK(!chain->findAncestorByHash(active[10]->GetBlockHash(), active[20]->GetBlockHash()));
98 auto* orig_tip = active.
Tip();
99 for (
int i = 0; i < 10; ++i) {
104 coinbaseKey.MakeNewKey(
true);
105 for (
int i = 0; i < 20; ++i) {
117 uint256 active_hash, orig_hash;
119 BOOST_CHECK(!chain->findCommonAncestor({}, orig_tip->GetBlockHash(), {}, {},
FoundBlock().hash(orig_hash)));
135 active[5]->nStatus &= ~BLOCK_HAVE_DATA;
141 active[95]->nStatus &= ~BLOCK_HAVE_DATA;
147 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.
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(findBlock)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
std::unique_ptr< ChainstateManager > chainman
std::unique_ptr< interfaces::Chain > chain
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.