#32229 tests: Add unix timestamp tests for OP_CLTV and max mediantimepast tests
https://github.com/bitcoin/bitcoin/pull/32229 · · +107/-7 in 2 files, 1 commits · labels: Tests
Goal
- Ensure consensus locktime rules are validated against median-time-past during block connection
- Add functional test coverage for boundary conditions near maximum timestamp values
This pull request adds functional test coverage for OP_CHECKLOCKTIMEVERIFY (BIP65) with unix-timestamp locktimes in feature_cltv.py, verifying that blocks are rejected until median-time-past satisfies the locktime. It also adds tests in feature_csv_activation.py for the BIP113 edge case where median-time-past reaches UINT32_MAX, showing that transactions with nLockTime equal to UINT32_MAX can never be mined.
Problem: While unit tests in transaction_tests.cpp test OP_CLTV script verification directly, functional tests do not verify the interaction between BIP65 unix-timestamp locktimes, median-time-past, and block connection. In addition, BIP113 behavior near the uint32 timestamp boundary has no functional test coverage.
Category: Test infrastructure (#23 of 45)
P3 · test coverage
- P3 because it adds functional regression coverage for existing consensus rules without fixing a bug
- Unit tests already cover script verification so the safety gain is modest
Worthwhile test coverage for consensus validation behavior under BIP65 and BIP113. While OP_CLTV timestamp validation is already tested at the unit level, testing block connection with median-time-past and documenting the UINT32_MAX boundary condition adds durable regression coverage.
Membership: Modifies functional tests under test/functional/ (feature_cltv.py and feature_csv_activation.py).
Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0
Reviewability: Ready
- Ready for review with passing tests
The PR is clean and tests pass. Recent review comments from sedited suggest minor cleanups and test additions, but nothing invalidates review.
Author status: active; last pushed on 2026-07-29, awaiting reply to sedited's review comments from 2026-09-16
Open concerns:
- sedited questioned several minor changes in feature_cltv.py that do not seem to alter test behavior (e.g. changing CLTV_HEIGHT from 111 to 112, mining 12 UTXOs instead of 11)
- sedited suggested expanding the UINT32_MAX test in feature_csv_activation.py to test mempool acceptance of UINT32_MAX - 1 timelocked transactions
Resolved concerns:
- Separated the BIP113 UINT32_MAX tests from feature_cltv.py into feature_csv_activation.py based on review feedback
- Clarified in the description that unit-level coverage for CLTV timestamps already exists in transaction_tests.cpp
Agreement: Positive
- Concept approval for adding the test coverage (sedited)
- Helped clarify the scope of existing unit tests versus functional tests (mabu44)
- Suggested expanding edge-case coverage and questioned minor parameter edits (sedited)
Concept ACK from sedited; discussion focuses on test placement and test edge-case accuracy
Reviewers have engaged constructively with no fundamental objections to adding the tests, and sedited provided a Concept ACK.
- mabu44 reviewed and helped clarify existing unit test coverage and integration test scope
- sedited offered Concept ACK and recommended moving the general BIP113 test to feature_csv_activation.py
- sedited provided inline review and suggested diff additions to improve edge-case testing
Review verdicts (DrahtBot): 0
- Concept ACK: sedited
Files
114 lines under test/bench/ci.
- test/functional/feature_csv_activation.py +66/-2
- test/functional/feature_cltv.py +41/-5
Card
Adds functional test coverage in feature_cltv.py and feature_csv_activation.py for OP_CHECKLOCKTIMEVERIFY with unix-timestamp locktimes and BIP113 median-time-past edge cases up to UINT32_MAX. It ensures blocks with CLTV-locked outputs are rejected until median-time-past passes the locktime, and confirms transactions locked to UINT32_MAX cannot be confirmed once MTP reaches the maximum uint32 value. Review is in a good state with a Concept ACK from sedited, who recently suggested refining the UINT32_MAX test cases.