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

Function BuildChain

src/test/validation_block_tests.cpp:103–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101}
102
103void 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)
104{
105 if (height <= 0 || blocks.size() >= max_size) return;
106
107 bool gen_invalid = GetRand(100) < invalid_rate;
108 bool gen_fork = GetRand(100) < branch_rate;
109
110 const std::shared_ptr<const CBlock> pblock = gen_invalid ? BadBlock(root) : GoodBlock(root);
111 blocks.push_back(pblock);
112 if (!gen_invalid) {
113 BuildChain(pblock->GetHash(), height - 1, invalid_rate, branch_rate, max_size, blocks);
114 }
115
116 if (gen_fork) {
117 blocks.push_back(GoodBlock(root));
118 BuildChain(blocks.back()->GetHash(), height - 1, invalid_rate, branch_rate, max_size, blocks);
119 }
120}
121
122BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
123{

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 6

GetRandFunction · 0.85
BadBlockFunction · 0.85
GoodBlockFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected