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

Function BOOST_AUTO_TEST_CASE

src/test/merkleblock_tests.cpp:20–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 * given block.
19 */
20BOOST_AUTO_TEST_CASE(merkleblock_construct_from_txids_found)
21{
22 CBlock block = getBlock13b8a();
23
24 std::set<uint256> txids;
25
26 // Last txn in block.
27 uint256 txhash1 = uint256S("0x74d681e0e03bafa802c8aa084379aa98d9fcd632ddc2ed9782b586ec87451f20");
28
29 // Second txn in block.
30 uint256 txhash2 = uint256S("0xf9fc751cb7dc372406a9f8d738d5e6f8f63bab71986a39cf36ee70ee17036d07");
31
32 txids.insert(txhash1);
33 txids.insert(txhash2);
34
35 CMerkleBlock merkleBlock(block, txids);
36
37 BOOST_CHECK_EQUAL(merkleBlock.header.GetHash().GetHex(), block.GetHash().GetHex());
38
39 // vMatchedTxn is only used when bloom filter is specified.
40 BOOST_CHECK_EQUAL(merkleBlock.vMatchedTxn.size(), 0U);
41
42 std::vector<uint256> vMatched;
43 std::vector<unsigned int> vIndex;
44
45 BOOST_CHECK_EQUAL(merkleBlock.txn.ExtractMatches(vMatched, vIndex).GetHex(), block.hashMerkleRoot.GetHex());
46 BOOST_CHECK_EQUAL(vMatched.size(), 2U);
47
48 // Ordered by occurrence in depth-first tree traversal.
49 BOOST_CHECK_EQUAL(vMatched[0].ToString(), txhash2.ToString());
50 BOOST_CHECK_EQUAL(vIndex[0], 1U);
51
52 BOOST_CHECK_EQUAL(vMatched[1].ToString(), txhash1.ToString());
53 BOOST_CHECK_EQUAL(vIndex[1], 8U);
54}
55
56
57/**

Callers

nothing calls this directly

Calls 8

getBlock13b8aFunction · 0.85
uint256SFunction · 0.85
insertMethod · 0.45
GetHexMethod · 0.45
GetHashMethod · 0.45
sizeMethod · 0.45
ExtractMatchesMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected