| 16 | BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup) |
| 17 | |
| 18 | BOOST_AUTO_TEST_CASE(findBlock) |
| 19 | { |
| 20 | auto& chain = m_node.chain; |
| 21 | const CChain& active = Assert(m_node.chainman)->ActiveChain(); |
| 22 | |
| 23 | uint256 hash; |
| 24 | BOOST_CHECK(chain->findBlock(active[10]->GetBlockHash(), FoundBlock().hash(hash))); |
| 25 | BOOST_CHECK_EQUAL(hash, active[10]->GetBlockHash()); |
| 26 | |
| 27 | int height = -1; |
| 28 | BOOST_CHECK(chain->findBlock(active[20]->GetBlockHash(), FoundBlock().height(height))); |
| 29 | BOOST_CHECK_EQUAL(height, active[20]->nHeight); |
| 30 | |
| 31 | CBlock data; |
| 32 | BOOST_CHECK(chain->findBlock(active[30]->GetBlockHash(), FoundBlock().data(data))); |
| 33 | BOOST_CHECK_EQUAL(data.GetHash(), active[30]->GetBlockHash()); |
| 34 | |
| 35 | int64_t time = -1; |
| 36 | BOOST_CHECK(chain->findBlock(active[40]->GetBlockHash(), FoundBlock().time(time))); |
| 37 | BOOST_CHECK_EQUAL(time, active[40]->GetBlockTime()); |
| 38 | |
| 39 | int64_t max_time = -1; |
| 40 | BOOST_CHECK(chain->findBlock(active[50]->GetBlockHash(), FoundBlock().maxTime(max_time))); |
| 41 | BOOST_CHECK_EQUAL(max_time, active[50]->GetBlockTimeMax()); |
| 42 | |
| 43 | int64_t mtp_time = -1; |
| 44 | BOOST_CHECK(chain->findBlock(active[60]->GetBlockHash(), FoundBlock().mtpTime(mtp_time))); |
| 45 | BOOST_CHECK_EQUAL(mtp_time, active[60]->GetMedianTimePast()); |
| 46 | |
| 47 | bool cur_active{false}, next_active{false}; |
| 48 | uint256 next_hash; |
| 49 | BOOST_CHECK_EQUAL(active.Height(), 100); |
| 50 | BOOST_CHECK(chain->findBlock(active[99]->GetBlockHash(), FoundBlock().inActiveChain(cur_active).nextBlock(FoundBlock().inActiveChain(next_active).hash(next_hash)))); |
| 51 | BOOST_CHECK(cur_active); |
| 52 | BOOST_CHECK(next_active); |
| 53 | BOOST_CHECK_EQUAL(next_hash, active[100]->GetBlockHash()); |
| 54 | cur_active = next_active = false; |
| 55 | BOOST_CHECK(chain->findBlock(active[100]->GetBlockHash(), FoundBlock().inActiveChain(cur_active).nextBlock(FoundBlock().inActiveChain(next_active)))); |
| 56 | BOOST_CHECK(cur_active); |
| 57 | BOOST_CHECK(!next_active); |
| 58 | |
| 59 | BOOST_CHECK(!chain->findBlock({}, FoundBlock())); |
| 60 | } |
| 61 | |
| 62 | BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight) |
| 63 | { |
nothing calls this directly
no test coverage detected