Add unittests for multiple ELSEs in a row

IF ELSE ELSE ENDIF is a valid construct; execution or non-execution
inverts on each ELSE encountered.
This commit is contained in:
Peter Todd 2013-07-23 05:12:38 -04:00
parent 0a740650a5
commit aff83e9c02
2 changed files with 30 additions and 1 deletions

View file

@ -13,7 +13,9 @@
["0","NOP"], ["0","NOP"],
["1", "IF VER ELSE 1 ENDIF", "VER non-functional"], ["1", "IF VER ELSE 1 ENDIF", "VER non-functional"],
["0", "IF VERIF ELSE 1 ENDIF", "VERIF illegal everywhere"], ["0", "IF VERIF ELSE 1 ENDIF", "VERIF illegal everywhere"],
["0", "IF VERNOTIF ELSE 1 ENDIF", "VERNOT illegal everywhere"], ["0", "IF ELSE 1 ELSE VERIF ENDIF", "VERIF illegal everywhere"],
["0", "IF VERNOTIF ELSE 1 ENDIF", "VERNOTIF illegal everywhere"],
["0", "IF ELSE 1 ELSE VERNOTIF ENDIF", "VERNOTIF illegal everywhere"],
["1 IF", "1 ENDIF", "IF/ENDIF can't span scriptSig/scriptPubKey"], ["1 IF", "1 ENDIF", "IF/ENDIF can't span scriptSig/scriptPubKey"],
["1 IF 0 ENDIF", "1 ENDIF"], ["1 IF 0 ENDIF", "1 ENDIF"],
@ -36,6 +38,18 @@
["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"], ["1 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"], ["0 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
["1", "IF RETURN ELSE ELSE 1 ENDIF", "Multiple ELSEs"],
["1", "IF 1 ELSE ELSE RETURN ENDIF"],
["1", "ENDIF", "Malformed IF/ELSE/ENDIF sequence"],
["1", "ELSE ENDIF"],
["1", "ENDIF ELSE"],
["1", "ENDIF ELSE IF"],
["1", "IF ELSE ENDIF ELSE"],
["1", "IF ELSE ENDIF ELSE ENDIF"],
["1", "IF ENDIF ENDIF"],
["1", "IF ELSE ELSE ENDIF ENDIF"],
["1", "RETURN"], ["1", "RETURN"],
["1", "DUP IF RETURN ENDIF"], ["1", "DUP IF RETURN ENDIF"],

View file

@ -34,6 +34,21 @@
["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"], ["1 0", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"], ["0 1", "NOTIF IF 1 ELSE 0 ENDIF ELSE IF 0 ELSE 1 ENDIF ENDIF"],
["0", "IF 0 ELSE 1 ELSE 0 ENDIF", "Multiple ELSE's are valid and executed inverts on each ELSE encountered"],
["1", "IF 1 ELSE 0 ELSE ENDIF"],
["1", "IF ELSE 0 ELSE 1 ENDIF"],
["1", "IF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL"],
["'' 1", "IF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL"],
["1", "NOTIF 0 ELSE 1 ELSE 0 ENDIF", "Multiple ELSE's are valid and execution inverts on each ELSE encountered"],
["0", "NOTIF 1 ELSE 0 ELSE ENDIF"],
["0", "NOTIF ELSE 0 ELSE 1 ENDIF"],
["0", "NOTIF 1 ELSE 0 ELSE 1 ENDIF ADD 2 EQUAL"],
["'' 0", "NOTIF SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ELSE ELSE SHA1 ENDIF 0x14 0x68ca4fec736264c13b859bac43d5173df6871682 EQUAL"],
["0", "IF 1 IF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 1 IF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL", "Nested ELSE ELSE"],
["1", "NOTIF 0 NOTIF RETURN ELSE RETURN ELSE RETURN ENDIF ELSE 0 NOTIF 1 ELSE RETURN ELSE 1 ENDIF ELSE RETURN ENDIF ADD 2 EQUAL"],
["0", "IF RETURN ENDIF 1", "RETURN only works if executed"], ["0", "IF RETURN ENDIF 1", "RETURN only works if executed"],
["1 1", "VERIFY"], ["1 1", "VERIFY"],