More test cases for transaction scripts #4560

pull OttoAllmendinger wants to merge 6 commits into bitcoin:master from OttoAllmendinger:more-test-cases changing 2 files +10 −0
  1. OttoAllmendinger commented at 12:32 PM on July 19, 2014: contributor

    These are some edge cases that I have detected using QuickCheck in the Haskoin project which are not covered by the existing test suite.

    In script_valid.json:

    1. All bytes of a boolean constant are significant, not only the last one. I had a dumb bug where I only checked the last byte, but it passed the test suite.
    2. Also casting the stack value to a 64 bit int works most of the time, unless the value overflows to 0. Added a test for that.
    3. SIZE does not consume the argument. Many commands consume the input argument, some don't, I think generally there could be more test coverage of that. Maybe build a test that puts a bunch of constants on the stack, execute a bunch of operations (for which the test makes sense) and test the value and stack depth in the end.

    In script_invalid.json:

    1. BOOLAND + BOOLOR have a slightly different conception of boolean values: these functions cast inputs to int64 and compare against zero, so they must fail for five-byte stack values.
    2. Limits for CHECKMULTISIG were not tested: (nKeys < 20) and (nSigs <= nKeys)
  2. additional test for OP_SIZE in script_valid.json ed02282bba
  3. script tests: BOOLAND, BOOLOR decode to integer
    unlike other boolean checks, arguments >5 bytes invalidate the script
    0072d98849
  4. script tests: values that overflow to 0 are true 833ff161bc
  5. script tests: value with trailing 0x00 is true 4cac5dbf83
  6. script test: test case for 5-byte bools 89101c6e78
  7. script tests: add tests for CHECKMULTISIG limits d2d9dc063f
  8. BitcoinPullTester commented at 12:57 PM on July 19, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4560_d2d9dc063f8da87e02e588064f8ea9253e201907/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  9. petertodd commented at 8:19 PM on July 21, 2014: contributor

    Stuff like the OP_SIZE makes me wonder if we should just add something that checks the exact stack returned by script evaluation. As this is consensus critical stuff it may even be worthwhile to just have a step-by-step stack trace that is compared exactly.

    But yeah, good tests! ACK

  10. sipa commented at 8:27 PM on July 21, 2014: member

    #3901 sounds really useful for implementing such tracing.

  11. petertodd commented at 8:40 PM on July 21, 2014: contributor

    @sipa Yes, but we could also do it with a lot less risk with a simple callback that if set took the state of execution as arguments. That'd keep the consensus-critical changes to an absolute minimum. #3901 would be safer to implement after we had testcases using the simpler callback mechanism too.

  12. laanwj commented at 7:53 AM on July 22, 2014: member

    @petertodd Good idea

  13. OttoAllmendinger commented at 10:27 AM on July 23, 2014: contributor

    Checking the the stack is also be possible by using EvalScript instead VerifyScript. In fact I found some of the bugs by comparing the stack after running EvalScript.

  14. laanwj merged this on Jul 31, 2014
  15. laanwj closed this on Jul 31, 2014

  16. laanwj referenced this in commit b7bba43a14 on Jul 31, 2014
  17. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 09:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me