Total money limit test #3707

pull sipa wants to merge 1 commits into bitcoin:master from sipa:moneyrange changing 2 files +18 −0
  1. sipa commented at 12:56 AM on February 19, 2014: member

    No description provided.

  2. Total money limit test 933e9a6a46
  3. BitcoinPullTester commented at 1:25 AM on February 19, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/933e9a6a4603f4e23e7572397f30fbb9628bf3c6 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. in src/test/main_tests.cpp:None in 933e9a6a46
       7 | +
       8 | +BOOST_AUTO_TEST_CASE(subsidy_limit_test)
       9 | +{
      10 | +    uint64_t nSum = 0;
      11 | +    for (int nHeight = 0; nHeight < 7000000; nHeight += 1000) {
      12 | +         nSum += GetBlockValue(nHeight, 0) * 1000;
    


    luke-jr commented at 1:40 AM on February 19, 2014:

    This looks like it can be easily broken by an overflow :(


    il--ya commented at 3:04 AM on February 19, 2014:

    // that would prevent overflow uint64_t subsidy = GetBlockValue(nHeight, 0); BOOST_CHECK(subsidy < 50 * COIN); nSum += subsidy * 1000;


    laanwj commented at 9:10 AM on February 19, 2014:

    More like

    uint64_t subsidy = GetBlockValue(nHeight, 0) * 1000;
    BOOST_CHECK((nSum + subsidy) >= nSum);
    nSum += subsidy;
    

    It's a pity that C++ still doesn't have a way to flag or raise exceptions on overflow.


    luke-jr commented at 9:18 AM on February 19, 2014:

    @laanwj If GetBlockValue returns > 2^64/1000, yours overflows undetectably. I think @il--ya 's is sound, though.


    laanwj commented at 9:24 AM on February 19, 2014:

    Oh crap, of course, the multiply can overflow too. Well that reinforces my point that writing code that handles overflows in C/C++ is just horribly frustrating. Edit: so yes, @il--ya's suggestion is better.

  5. laanwj commented at 9:48 AM on February 28, 2014: member

    See #3768

  6. laanwj closed this on Feb 28, 2014

  7. DrahtBot 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-04-13 21:15 UTC

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