MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/interfaces_tests.cpp:18–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16BOOST_FIXTURE_TEST_SUITE(interfaces_tests, TestChain100Setup)
17
18BOOST_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
62BOOST_AUTO_TEST_CASE(findFirstBlockWithTimeAndHeight)
63{

Callers

nothing calls this directly

Calls 15

FoundBlockClass · 0.85
GetScriptForRawPubKeyFunction · 0.85
findBlockMethod · 0.80
hashMethod · 0.80
GetBlockTimeMaxMethod · 0.80
GetMedianTimePastMethod · 0.80
HeightMethod · 0.80
findAncestorByHeightMethod · 0.80
findAncestorByHashMethod · 0.80
InvalidateBlockMethod · 0.80
MakeNewKeyMethod · 0.80

Tested by

no test coverage detected