diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2017-05-23 15:09:30 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2017-06-05 12:44:44 -0700 |
commit | 124d13a58cdcd9f66eeffc7e6281e3eb129e3398 (patch) | |
tree | 27b689722c38170f22543453fbf06b41fb336846 /src/test | |
parent | 90620d66c91ae91c0d5ce73582eb39c47e35ae98 (diff) |
Merge test_random.h into test_bitcoin.h
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/coins_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/crypto_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/merkle_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/pmt_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/prevector_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/sighash_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/skiplist_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/test_bitcoin.h | 19 | ||||
-rw-r--r-- | src/test/test_random.h | 29 | ||||
-rw-r--r-- | src/test/util_tests.cpp | 1 | ||||
-rw-r--r-- | src/test/versionbits_tests.cpp | 1 |
11 files changed, 19 insertions, 38 deletions
diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 0ed71b96fc..6073a9282c 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -8,7 +8,6 @@ #include "undo.h" #include "utilstrencodings.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include "validation.h" #include "consensus/validation.h" diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index 72e562808a..4b76cc1021 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -13,7 +13,6 @@ #include "random.h" #include "utilstrencodings.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <vector> diff --git a/src/test/merkle_tests.cpp b/src/test/merkle_tests.cpp index f2f06fa8e2..a86c4fa48d 100644 --- a/src/test/merkle_tests.cpp +++ b/src/test/merkle_tests.cpp @@ -4,7 +4,6 @@ #include "consensus/merkle.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <boost/test/unit_test.hpp> diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index a1cb32019a..e3a4f90aaf 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -10,7 +10,6 @@ #include "arith_uint256.h" #include "version.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <vector> diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index cfed5e347e..45bcac6837 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -9,7 +9,6 @@ #include "streams.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <boost/test/unit_test.hpp> diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index 2f7c22084e..f796216e5f 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -11,7 +11,6 @@ #include "serialize.h" #include "streams.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include "util.h" #include "utilstrencodings.h" #include "version.h" diff --git a/src/test/skiplist_tests.cpp b/src/test/skiplist_tests.cpp index 0b2fe0ef9d..9e09533b9b 100644 --- a/src/test/skiplist_tests.cpp +++ b/src/test/skiplist_tests.cpp @@ -5,7 +5,6 @@ #include "chain.h" #include "util.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <vector> diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h index 60a86d8c48..80d46e04a6 100644 --- a/src/test/test_bitcoin.h +++ b/src/test/test_bitcoin.h @@ -9,11 +9,30 @@ #include "fs.h" #include "key.h" #include "pubkey.h" +#include "random.h" #include "txdb.h" #include "txmempool.h" #include <boost/thread.hpp> +extern uint256 insecure_rand_seed; +extern FastRandomContext insecure_rand_ctx; + +static inline void seed_insecure_rand(bool fDeterministic = false) +{ + if (fDeterministic) { + insecure_rand_seed = uint256(); + } else { + insecure_rand_seed = GetRandHash(); + } + insecure_rand_ctx = FastRandomContext(insecure_rand_seed); +} + +static inline uint32_t insecure_rand(void) +{ + return insecure_rand_ctx.rand32(); +} + /** Basic testing setup. * This just configures logging and chain parameters. */ diff --git a/src/test/test_random.h b/src/test/test_random.h deleted file mode 100644 index 318c44df4d..0000000000 --- a/src/test/test_random.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2016 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_TEST_RANDOM_H -#define BITCOIN_TEST_RANDOM_H - -#include "random.h" - -extern uint256 insecure_rand_seed; -extern FastRandomContext insecure_rand_ctx; - -static inline void seed_insecure_rand(bool fDeterministic = false) -{ - if (fDeterministic) { - insecure_rand_seed = uint256(); - } else { - insecure_rand_seed = GetRandHash(); - } - insecure_rand_ctx = FastRandomContext(insecure_rand_seed); -} - -static inline uint32_t insecure_rand(void) -{ - return insecure_rand_ctx.rand32(); -} - -#endif diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 10330c0c23..3b3c929850 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -10,7 +10,6 @@ #include "utilstrencodings.h" #include "utilmoneystr.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include <stdint.h> #include <vector> diff --git a/src/test/versionbits_tests.cpp b/src/test/versionbits_tests.cpp index 79405ec4d1..5302af9464 100644 --- a/src/test/versionbits_tests.cpp +++ b/src/test/versionbits_tests.cpp @@ -5,7 +5,6 @@ #include "chain.h" #include "versionbits.h" #include "test/test_bitcoin.h" -#include "test/test_random.h" #include "chainparams.h" #include "validation.h" #include "consensus/params.h" |