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

Method BadBlock

src/test/validation_block_tests.cpp:117–130  ·  view source on GitHub ↗

construct an invalid block (but with a valid header)

Source from the content-addressed store, hash-verified

115
116// construct an invalid block (but with a valid header)
117std::shared_ptr<const CBlock> MinerTestingSetup::BadBlock(const uint256& prev_hash)
118{
119 auto pblock = Block(prev_hash);
120
121 CMutableTransaction coinbase_spend;
122 coinbase_spend.vin.push_back(CTxIn(COutPoint(pblock->vtx[0]->GetHash(), 0), CScript(), 0));
123 coinbase_spend.vout.push_back(pblock->vtx[0]->vout[0]);
124
125 CTransactionRef tx = MakeTransactionRef(coinbase_spend);
126 pblock->vtx.push_back(tx);
127
128 auto ret = FinalizeBlock(pblock);
129 return ret;
130}
131
132void MinerTestingSetup::BuildChain(const uint256& root, int height, const unsigned int invalid_rate, const unsigned int branch_rate, const unsigned int max_size, std::vector<std::shared_ptr<const CBlock>>& blocks)
133{

Callers

nothing calls this directly

Calls 7

BlockClass · 0.50
CTxInClass · 0.50
COutPointClass · 0.50
CScriptClass · 0.50
MakeTransactionRefFunction · 0.50
push_backMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected