diff options
| author | Wladimir J. van der Laan <[email protected]> | 2019-02-04 12:11:34 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2019-02-04 12:26:42 +0100 |
| commit | 424327e1a8f5ccc0ebd9265c50725d37093d5164 (patch) | |
| tree | 18359ab386826a982e7898514392456b59c16619 /src/random.cpp | |
| parent | Merge #15280: gui: Fix shutdown order (diff) | |
| parent | test: Make bloom tests deterministic (diff) | |
| download | discoin-424327e1a8f5ccc0ebd9265c50725d37093d5164.tar.xz discoin-424327e1a8f5ccc0ebd9265c50725d37093d5164.zip | |
Merge #15324: test: Make bloom tests deterministic
fae169c95e09ddf068dcaebc8170c4f41b02cf66 test: Make bloom tests deterministic (MarcoFalke)
Pull request description:
non-deterministic tests are useless, since a failing test could not be reproduced unless the seed is known.
Tree-SHA512: 4f634ff0c6adf663444f1ac504f6dbceaa46b78d697b840531977ba30006453ac559d5c21cc3eaef6d92b87d46008a34b0db6331ea3318001987fcfaec634acf
Diffstat (limited to 'src/random.cpp')
| -rw-r--r-- | src/random.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/random.cpp b/src/random.cpp index 3b7f7910b..3277c34d3 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -514,9 +514,11 @@ void GetRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNG void GetStrongRandBytes(unsigned char* buf, int num) noexcept { ProcRand(buf, num, RNGLevel::SLOW); } void RandAddSeedSleep() { ProcRand(nullptr, 0, RNGLevel::SLEEP); } +bool g_mock_deterministic_tests{false}; + uint64_t GetRand(uint64_t nMax) noexcept { - return FastRandomContext().randrange(nMax); + return FastRandomContext(g_mock_deterministic_tests).randrange(nMax); } int GetRandInt(int nMax) noexcept |