-
Notifications
You must be signed in to change notification settings - Fork 38.6k
test: check for all possible OP_CLTV fail reasons in feature_cltv.py (BIP 65) #19801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: check for all possible OP_CLTV fail reasons in feature_cltv.py (BIP 65) #19801
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
concept ACK |
dfdd34a to
0bf3040
Compare
|
Rebased on master. |
0bf3040 to
ebfc246
Compare
|
Rebased on master again. |
+ reformat python imports + fix PEP8 warnings (all except E501 line too long)
…cltv.py only the "top item on the stack is less than 0" is used in the test right now
ebfc246 to
b01cd94
Compare
|
Rebased on master. |
|
Concept ACK |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review ACK b01cd94 🐣
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK b01cd9471f435bb36b8ed5211a56baad51111ad2 🐣
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUiGwwv/ehsKGNFfYIyNn3Pb7H8mC7j6SfFijNHeg+rDldGw1lNA3MLjMvPGhs4v
+uuAbS74JCv4T6fEjw8K4ODx6ZU/+fyckT8HL2Qxx9TbqPN9+3Gc5Ww68137+RRW
mOzNy1S4Z6MPu3OtBZxkHSKHXPKF6sSTDyqjrxgslpOFNDceirBIahFTHPXy2geh
gZYLsQYtbY0kDJBLcfCh4vvPW5IpLO2Cr5iRQkVmj31upzvYniKmWtuCwmwrXZG9
mAKP0o9AGnfYWCufH1NpDBp4/JBrRITk+nz0bOgxYO99FiJMalX+YTP6xlkOIGgI
ChrXmz7/qe3FXypz9lA+hL44R7/ApLWhCfc4oK9bbHwSVqbjnTh5V20+EjYSK3ER
5IPjBDjbTN1768iQMRIjq2Aj9zQFrVwCkzlW56zwlECZoFHGEzDOWimHkVWd1vZR
qSvVIya8GmuqwWpEASi9O5yXArtqF+Vzr7s9Ki8TiTbGFOQFFlNFLgTXkOXi4Mrr
DC1R6djf
=TLhB
-----END PGP SIGNATURE-----
Timestamp of file with hash 0aea310db82e5dcfdbcc25d7e801d24635a1a608c8b997bbb98494c524f90747 -
|
Reworked the test some more in #21754 |
The functional test for BIP65 /
OP_CHECKLOCKTIMEVERIFY(feature_cltv.py) currently only tests one out of five conditions that lead to failure of the op-code -- by prepending the scriptOP_1NEGATE OP_CHECKLOCKTIMEVERIFY OP_DROPto a tx's first input's scriptSig, the case of "the top item on the stack is less than 0" is checked:bitcoin/test/functional/feature_cltv.py
Lines 26 to 35 in f8462a6
This PR adds the other cases (5 in total) by taking an integer argument to the function
cltv_invalidatethat is called in a loop instead of only once per testing scenario. Here is the full list of failure conditions and how they are tested (note that the scriptSig should still be valid before activation of BIP65, whenOP_CLTVis simply a no-op):➡️ prepending
OP_CHECKLOCKTIMEVERIFYto scriptSig➡️ prepending
OP_1NEGATE OP_CHECKLOCKTIMEVERIFY OP_DROPto scriptSig➡️ prepending
OPNum(1000) OP_CHECKLOCKTIMEVERIFY OP_DROPto scriptSig➡️ setting tx.vin[0].nSequence=0 and tx.nCheckTimeLock=1296688602 (genesis block timestamp)
➡️ prepending
OPNum(1000) OP_CHECKLOCKTIMEVERIFY OP_DROPto scriptSig➡️ setting tx.vin[0].nSequence=0 and tx.nCheckTimeLock=500
➡️ prepending
OPNum(500) OP_CHECKLOCKTIMEVERIFY OP_DROPto scriptSig➡️ setting tx.vin[0].nSequence=0xffffffff and tx.nCheckTimeLock=500
The first commit creates a helper function for the tx modification and also includes some tidying up like turning single-line to multi-line Python imports where necessary and cleaning up some PEP8 warnings. The second commit prepares the invalidation function
cltv_invalidateand the third and the fourth use it and check for the expected reject reason strings ("Operation not valid with the current stack size", "Negative locktime" and "Locktime requirement not satisfied").