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.
test: check tx is final when there is no locktime #33030
pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2025-07-test-isfinaltx-nlocktime-0 changing 1 files +4 −0-
brunoerg commented at 6:41 PM on July 21, 2025: contributor
- DrahtBot added the label Tests on Jul 21, 2025
-
DrahtBot commented at 6:41 PM on July 21, 2025: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33030.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
- darosior approved
-
darosior commented at 6:55 PM on July 21, 2025: member
Makes sense. utACK 7180b82420c0f303140a93ca635f5ac806bea77d. Could add a comment explaining this to the test as it may not be immediately obvious to a reader.
-
test: IsFinalTx returns true when there is no locktime 065e42976a
- brunoerg force-pushed on Jul 22, 2025
-
maflcko commented at 1:17 PM on July 22, 2025: member
lgtm ACK 065e42976a70738770af256da810ddc1316a4496
- DrahtBot requested review from darosior on Jul 22, 2025
-
in src/test/miner_tests.cpp:526 in 065e42976a
522 | @@ -523,6 +523,10 @@ void MinerTestingSetup::TestBasicMining(const CScript& scriptPubKey, const std:: 523 | BOOST_CHECK(TestSequenceLocks(CTransaction{tx}, tx_mempool)); // Sequence locks pass 524 | BOOST_CHECK(IsFinalTx(CTransaction(tx), m_node.chainman->ActiveChain().Tip()->nHeight + 2, m_node.chainman->ActiveChain().Tip()->GetMedianTimePast())); // Locktime passes on 2nd block 525 | 526 | + // ensure tx is final for a specific case where there is no locktime and block height is zero
darosior commented at 1:22 PM on July 22, 2025:nit, don't retouch this for me, but my point with the comment wasn't to describe the line below (anyone can just read block height is 0 and locktime is 0) but to describe why them both being 0 is a special case worth exercising, as you did in OP.
darosior approveddarosior commented at 1:22 PM on July 22, 2025: memberutACK 065e42976a70738770af256da810ddc1316a4496
enirox001 commented at 3:36 PM on July 22, 2025: contributorlgtm
ACK 065e429: Valuable test case that explicitly demonstrates
IsFinalTxbehavior when nLockTime is 0achow101 commented at 5:49 PM on July 22, 2025: memberACK 065e42976a70738770af256da810ddc1316a4496
achow101 merged this on Jul 22, 2025achow101 closed this on Jul 22, 2025brunoerg deleted the branch on Jul 22, 2025sedited referenced this in commit 02ded863ba on Jul 28, 2025sedited referenced this in commit 52d7f32bd6 on Jul 28, 2025alexanderwiederin referenced this in commit 28fe919bf7 on Aug 6, 2025sedited referenced this in commit b98d982d79 on Aug 7, 2025alexanderwiederin referenced this in commit 4152176d02 on Aug 8, 2025alexanderwiederin referenced this in commit 9ef94c31db on Aug 8, 2025stringintech referenced this in commit 71275a1b5e on Aug 17, 2025yuvicc referenced this in commit 22f55cf11d on Aug 26, 2025bug-castercv502 referenced this in commit 4aa5572aea on Sep 28, 2025stickies-v referenced this in commit a19c56cd7c on Nov 4, 2025Kino1994 referenced this in commit 06f4c68adb on Jun 28, 2026BigcoinBGC referenced this in commit 552e7a4a10 on Jun 30, 2026bitcoin locked this on Jul 30, 2026
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-11 10:51 UTC
More mirrored repositories can be found on mirror.b10c.me