test: Adds additional zero checks for setCompact #3559

pull TierNolan wants to merge 1 commits into bitcoin:master from TierNolan:zero_compact_tests changing 1 files +36 −0
  1. TierNolan commented at 2:16 PM on January 19, 2014: contributor

    This pull request adds additional checks to the setCompact() method for bignums.

    It covers various valid representations of zero (positive and negative). It tests that the non-zero portions of the encoding are correctly ignored and that they are re-encode back to all zeros.

    Positive Numbers 0x01003456 (1 byte 0x00) 0x02000056 (2 bytes 0x0000) 0x03000000 (3 bytes 0x000000) 0x04000000 (4 bytes 0x000000_00)

    Negative Numbers 0x00923456 -(0 bytes, so zero) 0x01803456 -(1 byte 0x00) 0x02800056 -(2 bytes 0x0000) 0x03800000 -(3 bytes 0x000000) 0x04800000 -(4 bytes 0x000000_00)

  2. Adds additional zero checks for setCompact
     These encoded values should all decode to zero
    
       Positive Numbers
        0x01003456 (1 byte  0x00)
        0x02000056 (2 bytes 0x0000)
        0x03000000 (3 bytes 0x000000)
        0x04000000 (4 bytes 0x000000_00)
    
       Negative Numbers
        0x00923456 -(0 bytes, so zero)
        0x01803456 -(1 byte  0x00)
        0x02800056 -(2 bytes 0x0000)
        0x03800000 -(3 bytes 0x000000)
        0x04800000 -(4 bytes 0x000000_00)
    e6c6bc92f4
  3. BitcoinPullTester commented at 2:58 PM on January 19, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/e6c6bc92f468b3eeffe1bd5ebc7b6c617bd31714 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.

  4. laanwj commented at 7:04 AM on January 21, 2014: member

    ACK

  5. laanwj referenced this in commit 12f5787d45 on Feb 25, 2014
  6. laanwj merged this on Feb 25, 2014
  7. laanwj closed this on Feb 25, 2014

  8. bitcoin 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-19 07:56 UTC

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