Changeset View
Changeset View
Standalone View
Standalone View
src/test/interfaces_tests.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(findBlock) { | ||||
int64_t mtp_time = -1; | int64_t mtp_time = -1; | ||||
BOOST_CHECK(chain->findBlock(active[60]->GetBlockHash(), | BOOST_CHECK(chain->findBlock(active[60]->GetBlockHash(), | ||||
FoundBlock().mtpTime(mtp_time))); | FoundBlock().mtpTime(mtp_time))); | ||||
BOOST_CHECK_EQUAL(mtp_time, active[60]->GetMedianTimePast()); | BOOST_CHECK_EQUAL(mtp_time, active[60]->GetMedianTimePast()); | ||||
BOOST_CHECK(!chain->findBlock(BlockHash(), FoundBlock())); | BOOST_CHECK(!chain->findBlock(BlockHash(), FoundBlock())); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight) { | |||||
auto chain = interfaces::MakeChain(m_node, Params()); | |||||
auto &active = ChainActive(); | |||||
BlockHash hash; | |||||
int height; | |||||
BOOST_CHECK(chain->findFirstBlockWithTimeAndHeight( | |||||
/* min_time= */ 0, /* min_height= */ 5, | |||||
FoundBlock().hash(hash).height(height))); | |||||
BOOST_CHECK_EQUAL(hash, active[5]->GetBlockHash()); | |||||
BOOST_CHECK_EQUAL(height, 5); | |||||
BOOST_CHECK(!chain->findFirstBlockWithTimeAndHeight( | |||||
/* min_time= */ active.Tip()->GetBlockTimeMax() + 1, | |||||
/* min_height= */ 0)); | |||||
} | |||||
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 42 Lines • Show Last 20 Lines |