tests: fix spurious windows test failures after 012598880c #5611

pull theuni wants to merge 1 commits into bitcoin:master from theuni:fix-rand-win-test changing 1 files +6 −4
  1. theuni commented at 1:13 AM on January 7, 2015: member

    Fixes for example: https://travis-ci.org/bitcoin/bitcoin/jobs/46093269 and https://travis-ci.org/bitcoin/bitcoin/jobs/46114383

    on rare occasions, rand() was returning duped values, causing duplicate transactions.

    BuildMerkleTree happily used these, but CPartialMerkleTree caught them and returned a null merkle root.

    Rather than taking chances with rand(), use the loop counter to guarantee unique values.

    At sipa's request, also remove the remaining uses of rand().

  2. tests: fix spurious windows test failures after 012598880c
    on rare occasions, rand() was returning duped values, causing duplicate
    transactions.
    
    BuildMerkleTree happily used these, but CPartialMerkleTree caught them and
    returned a null merkle root.
    
    Rather than taking changes with rand(), use the loop counter to guarantee
    unique values.
    
    At sipa's request, also remove the remaining uses of rand().
    f0b8afc88b
  3. Michagogo commented at 9:50 AM on January 7, 2015: contributor

    Switching from rand to insecure_rand prevents duplicates? How big is this random output exactly?

  4. sipa commented at 10:17 AM on January 7, 2015: member

    No, replacing the rand with deterministic, non-random variables prevents duplicates.

  5. Michagogo commented at 10:26 AM on January 7, 2015: contributor

    Oh, so the line in the 40s is the key change here. What's the difference between rand and insecure_rand, that the rest of the change switches to?

  6. laanwj commented at 10:55 AM on January 7, 2015: member

    @michagogo insecure_rand is under our full control, which means it's possible to replay tests that failed (even on a different platform with different libc), at least if we log the seed value. It also removes all platform dependent variability in random values used for testing.

  7. laanwj added the label Tests on Jan 7, 2015
  8. Michagogo commented at 11:15 AM on January 7, 2015: contributor

    Ah. Makes sense. Thanks! Just looked and realized that insecure_rand is something that is actually defined by one of our own files. That added include should have clued me in sooner… (I'm assuming that rand is a built-in RNG?)

    On Wednesday, January 7, 2015, Wladimir J. van der Laan < notifications@github.com> wrote:

    @michagogo https://github.com/michagogo insecure_rand is under our full control, which means it's possible to replay tests that failed (even on a different platform with different libc), at least if we log the seed value.

    — Reply to this email directly or view it on GitHub #5611 (comment).

  9. laanwj merged this on Jan 7, 2015
  10. laanwj closed this on Jan 7, 2015

  11. laanwj referenced this in commit 37b185c4af on Jan 7, 2015
  12. MarcoFalke locked this on Sep 8, 2021
Labels

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-18 15:15 UTC

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