Skip to content

Commit c76dbe9

Browse files
committed
qa: timelock coinbase transactions created in fuzz targets
1 parent 9c94069 commit c76dbe9

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/kernel/chainparams.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ class CRegTestParams : public CChainParams
589589
{
590590
// For use by fuzz target src/test/fuzz/utxo_snapshot.cpp
591591
.height = 200,
592-
.hash_serialized = AssumeutxoHash{uint256{"7e3b7780fbd2fa479a01f66950dc8f728dc1b11f03d06d5bf223168520df3a48"}},
592+
.hash_serialized = AssumeutxoHash{uint256{"17dcc016d188d16068907cdeb38b75691a118d43053b8cd6a25969419381d13a"}},
593593
.m_chain_tx_count = 201,
594-
.blockhash = consteval_ctor(uint256{"5e93653318f294fb5aa339d00bbf8cf1c3515488ad99412c37608b139ea63b27"}),
594+
.blockhash = consteval_ctor(uint256{"385901ccbd69dff6bbd00065d01fb8a9e464dede7cfe0372443884f9b1dcf6b9"}),
595595
},
596596
{
597597
// For use by test/functional/feature_assumeutxo.py

src/test/fuzz/utxo_total_supply.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ FUZZ_TARGET(utxo_total_supply)
5252
// Replace OP_FALSE with OP_TRUE
5353
{
5454
CMutableTransaction tx{*block->vtx.back()};
55+
tx.nLockTime = 0; // Use the same nLockTime for all as we want to duplicate one of them.
5556
tx.vout.at(0).scriptPubKey = CScript{} << OP_TRUE;
5657
block->vtx.back() = MakeTransactionRef(tx);
5758
}

src/test/util/mining.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <validationinterface.h>
1818
#include <versionbits.h>
1919

20+
#include <algorithm>
21+
2022
using node::BlockAssembler;
2123
using node::NodeContext;
2224

@@ -34,12 +36,15 @@ std::vector<std::shared_ptr<CBlock>> CreateBlockChain(size_t total_height, const
3436
{
3537
std::vector<std::shared_ptr<CBlock>> ret{total_height};
3638
auto time{params.GenesisBlock().nTime};
39+
// NOTE: here `height` does not correspond to the block height but the block height - 1.
3740
for (size_t height{0}; height < total_height; ++height) {
3841
CBlock& block{*(ret.at(height) = std::make_shared<CBlock>())};
3942

4043
CMutableTransaction coinbase_tx;
44+
coinbase_tx.nLockTime = static_cast<uint32_t>(height);
4145
coinbase_tx.vin.resize(1);
4246
coinbase_tx.vin[0].prevout.SetNull();
47+
coinbase_tx.vin[0].nSequence = CTxIn::MAX_SEQUENCE_NONFINAL; // Make sure timelock is enforced.
4348
coinbase_tx.vout.resize(1);
4449
coinbase_tx.vout[0].scriptPubKey = P2WSH_OP_TRUE;
4550
coinbase_tx.vout[0].nValue = GetBlockSubsidy(height + 1, params.GetConsensus());

0 commit comments

Comments
 (0)