Changeset View
Changeset View
Standalone View
Standalone View
src/test/interfaces_tests.cpp
Show First 20 Lines • Show All 44 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(findAncestorByHash) { | |||||
auto chain = interfaces::MakeChain(m_node, Params()); | |||||
auto &active = ChainActive(); | |||||
int height = -1; | |||||
BOOST_CHECK(chain->findAncestorByHash(active[20]->GetBlockHash(), | |||||
active[10]->GetBlockHash(), | |||||
FoundBlock().height(height))); | |||||
BOOST_CHECK_EQUAL(height, 10); | |||||
BOOST_CHECK(!chain->findAncestorByHash(active[10]->GetBlockHash(), | |||||
active[20]->GetBlockHash())); | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |