mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-26 00:51:38 +02:00
Merge bitcoin/bitcoin#33030: test: check tx is final when there is no locktime
065e42976a
test: IsFinalTx returns true when there is no locktime (brunoerg) Pull request description: According to https://corecheck.dev/mutation/src/consensus/tx_verify.cpp, there is no proper test for the `tx.nLockTime == 0` check in the `IsFinalTx` function, which is understandable, since this check will only be useful for a specific case where the `nBlockHeight` (block height) is zero. Otherwise, the following check `if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))` would catch any of it. This PR adds a test case for it. ACKs for top commit: maflcko: lgtm ACK065e42976a
enirox001: ACK065e429
: Valuable test case that explicitly demonstrates `IsFinalTx` behavior when nLockTime is 0 achow101: ACK065e42976a
darosior: utACK065e42976a
Tree-SHA512: e44a7c060bd4c3d746fab166442cadc3fd449ddd8b02cabf22024a5dde6f438f24c6e1bff2a6dc49b57c8e01234aa0fd393fbfe6194df9d9b6c3d4fa2655c99b
This commit is contained in:
@@ -523,6 +523,10 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std::
|
||||
BOOST_CHECK(TestSequenceLocks(CTransaction{tx}, tx_mempool)); // Sequence locks pass
|
||||
BOOST_CHECK(IsFinalTx(CTransaction(tx), m_node.chainman->ActiveChain().Tip()->nHeight + 2, m_node.chainman->ActiveChain().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block
|
||||
|
||||
// ensure tx is final for a specific case where there is no locktime and block height is zero
|
||||
tx.nLockTime = 0;
|
||||
BOOST_CHECK(IsFinalTx(CTransaction(tx), /*nBlockHeight=*/0, m_node.chainman->ActiveChain().Tip()->GetMedianTimePast()));
|
||||
|
||||
// absolute time locked
|
||||
tx.vin[0].prevout.hash = txFirst[3]->GetHash();
|
||||
tx.nLockTime = m_node.chainman->ActiveChain().Tip()->GetMedianTimePast();
|
||||
|
Reference in New Issue
Block a user