Changeset View
Changeset View
Standalone View
Standalone View
src/test/interfaces_tests.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | BOOST_CHECK(chain->findFirstBlockWithTimeAndHeight( | ||||
FoundBlock().hash(hash).height(height))); | FoundBlock().hash(hash).height(height))); | ||||
BOOST_CHECK_EQUAL(hash, active[5]->GetBlockHash()); | BOOST_CHECK_EQUAL(hash, active[5]->GetBlockHash()); | ||||
BOOST_CHECK_EQUAL(height, 5); | BOOST_CHECK_EQUAL(height, 5); | ||||
BOOST_CHECK(!chain->findFirstBlockWithTimeAndHeight( | BOOST_CHECK(!chain->findFirstBlockWithTimeAndHeight( | ||||
/* min_time= */ active.Tip()->GetBlockTimeMax() + 1, | /* min_time= */ active.Tip()->GetBlockTimeMax() + 1, | ||||
/* min_height= */ 0)); | /* min_height= */ 0)); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(findNextBlock) { | |||||
auto chain = interfaces::MakeChain(m_node, Params()); | |||||
auto &active = ChainActive(); | |||||
bool reorg; | |||||
BlockHash hash; | |||||
BOOST_CHECK(chain->findNextBlock(active[20]->GetBlockHash(), 20, | |||||
FoundBlock().hash(hash), &reorg)); | |||||
BOOST_CHECK_EQUAL(hash, active[21]->GetBlockHash()); | |||||
BOOST_CHECK_EQUAL(reorg, false); | |||||
BOOST_CHECK(!chain->findNextBlock(BlockHash(), 20, {}, &reorg)); | |||||
BOOST_CHECK_EQUAL(reorg, true); | |||||
BOOST_CHECK(!chain->findNextBlock(active.Tip()->GetBlockHash(), | |||||
active.Height(), {}, &reorg)); | |||||
BOOST_CHECK_EQUAL(reorg, false); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(findAncestorByHeight) { | BOOST_AUTO_TEST_CASE(findAncestorByHeight) { | ||||
auto chain = interfaces::MakeChain(m_node, Params()); | auto chain = interfaces::MakeChain(m_node, Params()); | ||||
auto &active = ChainActive(); | auto &active = ChainActive(); | ||||
BlockHash hash; | BlockHash hash; | ||||
BOOST_CHECK(chain->findAncestorByHeight(active[20]->GetBlockHash(), 10, | BOOST_CHECK(chain->findAncestorByHeight(active[20]->GetBlockHash(), 10, | ||||
FoundBlock().hash(hash))); | FoundBlock().hash(hash))); | ||||
BOOST_CHECK_EQUAL(hash, active[10]->GetBlockHash()); | BOOST_CHECK_EQUAL(hash, active[10]->GetBlockHash()); | ||||
BOOST_CHECK(!chain->findAncestorByHeight(active[10]->GetBlockHash(), 20)); | BOOST_CHECK(!chain->findAncestorByHeight(active[10]->GetBlockHash(), 20)); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |