MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BOOST_FIXTURE_TEST_CASE

Function BOOST_FIXTURE_TEST_CASE

src/test/interfaces_tests.cpp:19–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

FoundBlockClass · 0.85
GetScriptForRawPubKeyFunction · 0.85
findBlockMethod · 0.80
heightMethod · 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