MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / BuildBlockTestCase

Function BuildBlockTestCase

src/test/blockencodings_tests.cpp:23–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 10

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

Tested by

no test coverage detected