Skip to content
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

CLTV: Add more tests to improve coverage #6368

Merged
merged 1 commit into from Jul 9, 2015
Merged

CLTV: Add more tests to improve coverage #6368

merged 1 commit into from Jul 9, 2015

Conversation

eordano
Copy link
Contributor

@eordano eordano commented Jul 3, 2015

This should be a pretty straightforward code review, adding a few tests to the script interpreter when CHECKLOCKTIMEVERIFY is enabled.

The test cases improve coverage for these cases:

  • 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)

@laanwj laanwj added the Tests label Jul 3, 2015
@@ -185,5 +185,21 @@
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "HASH160 0x14 0xc5b93064159b3b2d6ab506a41b1f50463771b988 EQUAL"]],
"0100000001000100000000000000000000000000000000000000000000000000000000000000000000030251b1000000000100000000000000000000000000", "P2SH,CHECKLOCKTIMEVERIFY"],

["Failure due to non-matching CHECKLOCKTIMEVERIFY kind"],
[[["0000000000000000000000000000000000000000000000000000000000000100", 0, "1"]],
"01000000010001000000000000000000000000000000000000000000000000000000000000000000000251b100000000010000000000000000000065cd1d", "P2SH,CHECKLOCKTIMEVERIFY"],
Copy link
Contributor

@petertodd petertodd Jul 3, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems that this test is nearly identical to the one at https://github.com/eordano/bitcoin/blob/test/cltv/src/test/data/tx_invalid.json#L160, other than being in the scriptSig vs. scriptPubKey, and using 1 as the threshold rather than 0. Is that correct, or am I misunderstanding something?

@petertodd
Copy link
Contributor

petertodd commented Jul 3, 2015

Thanks for the review!

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)
@petertodd
Copy link
Contributor

petertodd commented Jul 9, 2015

Looks good now, ACK

@laanwj
Copy link
Member

laanwj commented Jul 9, 2015

ACK

@laanwj laanwj merged commit cb54d17 into bitcoin:master Jul 9, 2015
1 check passed
laanwj added a commit that referenced this issue Jul 9, 2015
cb54d17 CLTV: Add more tests to improve coverage (Esteban Ordano)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants