diff --git a/src/test/blockfilter_index_tests.cpp b/src/test/blockfilter_index_tests.cpp index 4b576bb084f..81119f52b19 100644 --- a/src/test/blockfilter_index_tests.cpp +++ b/src/test/blockfilter_index_tests.cpp @@ -81,6 +81,7 @@ CBlock BuildChainTestingSetup::CreateBlock(const CBlockIndex* prev, } { CMutableTransaction tx_coinbase{*block.vtx.at(0)}; + tx_coinbase.nLockTime = static_cast(prev->nHeight); tx_coinbase.vin.at(0).scriptSig = CScript{} << prev->nHeight + 1; block.vtx.at(0) = MakeTransactionRef(std::move(tx_coinbase)); block.hashMerkleRoot = BlockMerkleRoot(block); diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 5c1f195868b..a0b23f5d3b7 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -82,7 +82,9 @@ std::shared_ptr MinerTestingSetup::Block(const uint256& prev_hash) 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; + const int prev_height{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(prev_hash)->nHeight)}; + txCoinbase.vin[0].scriptSig = CScript{} << prev_height + 1 << OP_0; + txCoinbase.nLockTime = static_cast(prev_height); pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase)); return pblock;