mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
test: Set BIP34Height = 2 for regtest
This commit is contained in:
@@ -77,6 +77,8 @@ std::shared_ptr<CBlock> MinerTestingSetup::Block(const uint256& prev_hash)
|
||||
txCoinbase.vout[1].nValue = txCoinbase.vout[0].nValue;
|
||||
txCoinbase.vout[0].nValue = 0;
|
||||
txCoinbase.vin[0].scriptWitness.SetNull();
|
||||
// Always pad with OP_0 at the end to avoid bad-cb-length error
|
||||
txCoinbase.vin[0].scriptSig = CScript{} << WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(prev_hash)->nHeight + 1) << OP_0;
|
||||
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
|
||||
|
||||
return pblock;
|
||||
@@ -84,8 +86,8 @@ std::shared_ptr<CBlock> MinerTestingSetup::Block(const uint256& prev_hash)
|
||||
|
||||
std::shared_ptr<CBlock> MinerTestingSetup::FinalizeBlock(std::shared_ptr<CBlock> pblock)
|
||||
{
|
||||
LOCK(cs_main); // For m_node.chainman->m_blockman.LookupBlockIndex
|
||||
GenerateCoinbaseCommitment(*pblock, m_node.chainman->m_blockman.LookupBlockIndex(pblock->hashPrevBlock), Params().GetConsensus());
|
||||
const CBlockIndex* prev_block{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(pblock->hashPrevBlock))};
|
||||
GenerateCoinbaseCommitment(*pblock, prev_block, Params().GetConsensus());
|
||||
|
||||
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
|
||||
|
||||
@@ -93,6 +95,11 @@ std::shared_ptr<CBlock> MinerTestingSetup::FinalizeBlock(std::shared_ptr<CBlock>
|
||||
++(pblock->nNonce);
|
||||
}
|
||||
|
||||
// submit block header, so that miner can get the block height from the
|
||||
// global state and the node has the topology of the chain
|
||||
BlockValidationState ignored;
|
||||
BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlockHeaders({pblock->GetBlockHeader()}, ignored, Params()));
|
||||
|
||||
return pblock;
|
||||
}
|
||||
|
||||
@@ -147,13 +154,6 @@ BOOST_AUTO_TEST_CASE(processnewblock_signals_ordering)
|
||||
}
|
||||
|
||||
bool ignored;
|
||||
BlockValidationState state;
|
||||
std::vector<CBlockHeader> headers;
|
||||
std::transform(blocks.begin(), blocks.end(), std::back_inserter(headers), [](std::shared_ptr<const CBlock> b) { return b->GetBlockHeader(); });
|
||||
|
||||
// Process all the headers so we understand the toplogy of the chain
|
||||
BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlockHeaders(headers, state, Params()));
|
||||
|
||||
// Connect the genesis block and drain any outstanding events
|
||||
BOOST_CHECK(Assert(m_node.chainman)->ProcessNewBlock(Params(), std::make_shared<CBlock>(Params().GenesisBlock()), true, &ignored));
|
||||
SyncWithValidationInterfaceQueue();
|
||||
|
||||
Reference in New Issue
Block a user