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

Function BuildBlockTestCase

src/test/blockencodings_tests.cpp:19–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegTestingSetup)
18
19static CBlock BuildBlockTestCase() {
20 CBlock block;
21 CMutableTransaction tx;
22 tx.vin.resize(1);
23 tx.vin[0].scriptSig.resize(10);
24 tx.vout.resize(1);
25 tx.vout[0].nValue = 42;
26
27 block.vtx.resize(3);
28 block.vtx[0] = MakeTransactionRef(tx);
29 block.nVersion = 42;
30 block.hashPrevBlock = InsecureRand256();
31 block.nBits = 0x207fffff;
32
33 tx.vin[0].prevout.hash = InsecureRand256();
34 tx.vin[0].prevout.n = 0;
35 block.vtx[1] = MakeTransactionRef(tx);
36
37 tx.vin.resize(10);
38 for (size_t i = 0; i < tx.vin.size(); i++) {
39 tx.vin[i].prevout.hash = InsecureRand256();
40 tx.vin[i].prevout.n = 0;
41 }
42 block.vtx[2] = MakeTransactionRef(tx);
43
44 bool mutated;
45 block.hashMerkleRoot = BlockMerkleRoot(block, &mutated);
46 assert(!mutated);
47 while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce;
48 return block;
49}
50
51// Number of shared use_counts we expect for a tx we haven't touched
52// (block + mempool + our copy from the GetSharedTx call)

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 8

InsecureRand256Function · 0.85
BlockMerkleRootFunction · 0.85
CheckProofOfWorkFunction · 0.85
MakeTransactionRefFunction · 0.50
ParamsClass · 0.50
resizeMethod · 0.45
sizeMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected