Skip to content

CLTV: Add more tests to improve coverage#6368

Merged
laanwj merged 1 commit intobitcoin:masterfrom
eordano:test/cltv
Jul 9, 2015
Merged

CLTV: Add more tests to improve coverage#6368
laanwj merged 1 commit intobitcoin:masterfrom
eordano:test/cltv

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
Copy link
Contributor

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

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

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
laanwj added a commit that referenced this pull request 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.

3 participants