test: Avoid testing negative block heights #24237

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2202-intHeight changing 3 files +4 −5
  1. MarcoFalke commented at 2:32 PM on February 2, 2022: member

    A negative chain height is only used to denote an empty chain, not the height of any block.

    So stop testing that and remove a suppression.

  2. test: Avoid testing negative block heights fad81548fa
  3. laanwj added the label Tests on Feb 2, 2022
  4. brunoerg approved
  5. brunoerg commented at 11:32 AM on February 3, 2022: member

    crACK fad81548fa03861c244397201d6b6e6cbf883c38

  6. in src/test/coins_tests.cpp:327 in fad81548fa
     323 | @@ -324,7 +324,7 @@ BOOST_AUTO_TEST_CASE(updatecoins_simulation_test)
     324 |              tx.vout.resize(1);
     325 |              tx.vout[0].nValue = i; //Keep txs unique unless intended to duplicate
     326 |              tx.vout[0].scriptPubKey.assign(InsecureRand32() & 0x3F, 0); // Random sizes so we can test memory usage accounting
     327 | -            unsigned int height = InsecureRand32();
     328 | +            const int height{int(InsecureRand32() >> 1)};
    


    PastaPastaPasta commented at 9:16 AM on February 7, 2022:

    use we just use GetRandInt from random.h?


    MarcoFalke commented at 9:53 AM on February 7, 2022:

    Might be better to do this in a separate pull request unrelated from the changes here?


    PastaPastaPasta commented at 10:22 AM on February 7, 2022:

    meh, what's the point of a new PR just for that? Probably no-one would review it 😂 imo, it makes much more sense here


    MarcoFalke commented at 10:38 AM on February 7, 2022:

    GetRandInt is either non-deterministic, or returns a constant (deterministic). Can you explain why either change makes sense? I'd say neither does and it should be left-as is.


    PastaPastaPasta commented at 12:01 PM on February 7, 2022:

    Ahh, okay, that's a good reason :) Maybe in the future we should adjust InsecureRand32 to make it clearer that it can be deterministic

  7. MarcoFalke merged this on Feb 7, 2022
  8. MarcoFalke closed this on Feb 7, 2022

  9. MarcoFalke deleted the branch on Feb 7, 2022
  10. sidhujag referenced this in commit 6c8c957bfe on Feb 7, 2022
  11. Fabcien referenced this in commit 32d5b6c9cf on Dec 9, 2022
  12. DrahtBot locked this on Feb 7, 2023

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-17 06:14 UTC

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