Skip to content

Commit cb54d17

Browse files
committed
CLTV: Add more tests to improve coverage
Four cases included: * The CLTV operand type mismatches the tx locktime. In the script it is 1 (interpreted as block height), but in the tx is 500000000 (interpreted as date) * The stack is empty when executing OP_CLTV * The tx is final by having only one input with MAX_INT sequence number * The operand for CLTV is negative (after OP_0 OP_1 OP_SUB)
1 parent 56dc704 commit cb54d17

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/data/tx_invalid.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@
137137
["Argument missing"],
138138
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "NOP2 1"]],
139139
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
140+
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
141+
"010000000100010000000000000000000000000000000000000000000000000000000000000000000001b1010000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
140142

141143
["Argument negative with by-blockheight nLockTime=0"],
142144
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 NOP2 1"]],
@@ -145,10 +147,14 @@
145147
["Argument negative with by-blocktime nLockTime=500,000,000"],
146148
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "-1 NOP2 1"]],
147149
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
150+
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
151+
"010000000100010000000000000000000000000000000000000000000000000000000000000000000004005194b1010000000100000000000000000002000000", "P2SH,CHECKLOCKTIMEVERIFY"],
148152

149153
["Input locked"],
150154
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 NOP2 1"]],
151155
"010000000100010000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],
156+
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0"]],
157+
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b1ffffffff0100000000000000000002000000", "P2SH,CHECKLOCKTIMEVERIFY"],
152158

153159
["Another input being unlocked isn't sufficient; the CHECKLOCKTIMEVERIFY-using input must be unlocked"],
154160
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 NOP2 1"] ,
@@ -158,6 +164,8 @@
158164
["Argument/tx height/time mismatch, both versions"],
159165
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0 NOP2 1"]],
160166
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
167+
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "0"]],
168+
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b100000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
161169
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "499999999 NOP2 1"]],
162170
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
163171
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "500000000 NOP2 1"]],

0 commit comments

Comments
 (0)