mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
Move random test util code from setup_common to random
as many of the unit tests don't use this code
This commit is contained in:
parent
52ddbd52f9
commit
81f5ade2a3
35 changed files with 73 additions and 6 deletions
|
@ -14,6 +14,7 @@ TEST_UTIL_H = \
|
|||
test/util/logging.h \
|
||||
test/util/mining.h \
|
||||
test/util/net.h \
|
||||
test/util/random.h \
|
||||
test/util/script.h \
|
||||
test/util/setup_common.h \
|
||||
test/util/str.h \
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <base58.h>
|
||||
#include <test/util/json.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/vector.h>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <consensus/merkle.h>
|
||||
#include <pow.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/txmempool.h>
|
||||
|
||||
#include <test/util/setup_common.h>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <random.h>
|
||||
#include <serialize.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <util/strencodings.h>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <checkqueue.h>
|
||||
#include <sync.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/system.h>
|
||||
#include <util/time.h>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <coins.h>
|
||||
#include <script/standard.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txdb.h>
|
||||
#include <uint256.h>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <crypto/muhash.h>
|
||||
#include <random.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// Copyright (c) 2012-2021 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <cuckoocache.h>
|
||||
#include <random.h>
|
||||
#include <script/sigcache.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <dbwrapper.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <util/string.h>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <clientversion.h>
|
||||
#include <crypto/siphash.h>
|
||||
#include <hash.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <key_io.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <util/strencodings.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <consensus/merkle.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <node/miner.h>
|
||||
#include <policy/policy.h>
|
||||
#include <script/standard.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/txmempool.h>
|
||||
#include <timedata.h>
|
||||
#include <txmempool.h>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <minisketch.h>
|
||||
#include <node/minisketchwrapper.h>
|
||||
#include <random.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <script/sign.h>
|
||||
#include <script/signingprovider.h>
|
||||
#include <script/standard.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txorphanage.h>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <merkleblock.h>
|
||||
#include <serialize.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <version.h>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <pow.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <serialize.h>
|
||||
#include <streams.h>
|
||||
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <script/signingprovider.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/json.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <test/util/transaction_utils.h>
|
||||
#include <util/strencodings.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <hash.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/serfloat.h>
|
||||
#include <serialize.h>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <streams.h>
|
||||
#include <test/data/sighash.json.h>
|
||||
#include <test/util/json.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <chain.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <vector>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <fs.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <script/standard.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/json.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/script.h>
|
||||
#include <test/util/transaction_utils.h>
|
||||
#include <util/strencodings.h>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <primitives/transaction.h>
|
||||
#include <script/script.h>
|
||||
#include <script/standard.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <validation.h>
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <txrequest.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
|
39
src/test/util/random.h
Normal file
39
src/test/util/random.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Copyright (c) 2023 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_UTIL_RANDOM_H
|
||||
#define BITCOIN_TEST_UTIL_RANDOM_H
|
||||
|
||||
#include <random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
static inline uint32_t InsecureRand32()
|
||||
{
|
||||
return g_insecure_rand_ctx.rand32();
|
||||
}
|
||||
|
||||
static inline uint256 InsecureRand256()
|
||||
{
|
||||
return g_insecure_rand_ctx.rand256();
|
||||
}
|
||||
|
||||
static inline uint64_t InsecureRandBits(int bits)
|
||||
{
|
||||
return g_insecure_rand_ctx.randbits(bits);
|
||||
}
|
||||
|
||||
static inline uint64_t InsecureRandRange(uint64_t range)
|
||||
{
|
||||
return g_insecure_rand_ctx.randrange(range);
|
||||
}
|
||||
|
||||
static inline bool InsecureRandBool()
|
||||
{
|
||||
return g_insecure_rand_ctx.randbool();
|
||||
}
|
||||
|
||||
#endif // BITCOIN_TEST_UTIL_RANDOM_H
|
|
@ -71,12 +71,6 @@ static inline void SeedInsecureRand(SeedRand seed = SeedRand::SEED)
|
|||
}
|
||||
}
|
||||
|
||||
static inline uint32_t InsecureRand32() { return g_insecure_rand_ctx.rand32(); }
|
||||
static inline uint256 InsecureRand256() { return g_insecure_rand_ctx.rand256(); }
|
||||
static inline uint64_t InsecureRandBits(int bits) { return g_insecure_rand_ctx.randbits(bits); }
|
||||
static inline uint64_t InsecureRandRange(uint64_t range) { return g_insecure_rand_ctx.randrange(range); }
|
||||
static inline bool InsecureRandBool() { return g_insecure_rand_ctx.randbool(); }
|
||||
|
||||
static constexpr CAmount CENT{1000000};
|
||||
|
||||
/** Basic testing setup.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <hash.h> // For Hash()
|
||||
#include <key.h> // For CKey
|
||||
#include <sync.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <util/getuniquepath.h>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <pow.h>
|
||||
#include <random.h>
|
||||
#include <script/standard.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/script.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/time.h>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <rpc/blockchain.h>
|
||||
#include <sync.h>
|
||||
#include <test/util/chainstate.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <uint256.h>
|
||||
#include <validation.h>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <rpc/blockchain.h>
|
||||
#include <sync.h>
|
||||
#include <test/util/chainstate.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <timedata.h>
|
||||
#include <uint256.h>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
//
|
||||
#include <sync.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <validation.h>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <consensus/params.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <wallet/crypter.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue