mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 12:52:35 -03:00
test: Make g_insecure_rand_ctx thread_local
This commit is contained in:
parent
9a43344430
commit
faead93c6c
3 changed files with 21 additions and 23 deletions
|
@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(outbound_slow_chain_eviction)
|
||||||
|
|
||||||
static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerLogicValidation &peerLogic)
|
static void AddRandomOutboundPeer(std::vector<CNode *> &vNodes, PeerLogicValidation &peerLogic)
|
||||||
{
|
{
|
||||||
CAddress addr(ip(insecure_rand_ctx.randbits(32)), NODE_NONE);
|
CAddress addr(ip(g_insecure_rand_ctx.randbits(32)), NODE_NONE);
|
||||||
vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK|NODE_WITNESS), 0, INVALID_SOCKET, addr, 0, 0, CAddress(), "", /*fInboundIn=*/ false));
|
vNodes.emplace_back(new CNode(id++, ServiceFlags(NODE_NETWORK|NODE_WITNESS), 0, INVALID_SOCKET, addr, 0, 0, CAddress(), "", /*fInboundIn=*/ false));
|
||||||
CNode &node = *vNodes.back();
|
CNode &node = *vNodes.back();
|
||||||
node.SetSendVersion(PROTOCOL_VERSION);
|
node.SetSendVersion(PROTOCOL_VERSION);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <crypto/sha256.h>
|
#include <crypto/sha256.h>
|
||||||
#include <miner.h>
|
#include <miner.h>
|
||||||
#include <net_processing.h>
|
#include <net_processing.h>
|
||||||
|
#include <noui.h>
|
||||||
#include <pow.h>
|
#include <pow.h>
|
||||||
#include <rpc/register.h>
|
#include <rpc/register.h>
|
||||||
#include <rpc/server.h>
|
#include <rpc/server.h>
|
||||||
|
@ -36,10 +37,7 @@ void CConnmanTest::ClearNodes()
|
||||||
g_connman->vNodes.clear();
|
g_connman->vNodes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
FastRandomContext insecure_rand_ctx;
|
thread_local FastRandomContext g_insecure_rand_ctx;
|
||||||
|
|
||||||
extern bool fPrintToConsole;
|
|
||||||
extern void noui_connect();
|
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const uint256& num)
|
std::ostream& operator<<(std::ostream& os, const uint256& num)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,18 +26,18 @@ std::ostream& operator<<(typename std::enable_if<std::is_enum<T>::value, std::os
|
||||||
return stream << static_cast<typename std::underlying_type<T>::type>(e);
|
return stream << static_cast<typename std::underlying_type<T>::type>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern FastRandomContext insecure_rand_ctx;
|
thread_local extern FastRandomContext g_insecure_rand_ctx;
|
||||||
|
|
||||||
static inline void SeedInsecureRand(bool deterministic = false)
|
static inline void SeedInsecureRand(bool deterministic = false)
|
||||||
{
|
{
|
||||||
insecure_rand_ctx = FastRandomContext(deterministic);
|
g_insecure_rand_ctx = FastRandomContext(deterministic);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t InsecureRand32() { return insecure_rand_ctx.rand32(); }
|
static inline uint32_t InsecureRand32() { return g_insecure_rand_ctx.rand32(); }
|
||||||
static inline uint256 InsecureRand256() { return insecure_rand_ctx.rand256(); }
|
static inline uint256 InsecureRand256() { return g_insecure_rand_ctx.rand256(); }
|
||||||
static inline uint64_t InsecureRandBits(int bits) { return insecure_rand_ctx.randbits(bits); }
|
static inline uint64_t InsecureRandBits(int bits) { return g_insecure_rand_ctx.randbits(bits); }
|
||||||
static inline uint64_t InsecureRandRange(uint64_t range) { return insecure_rand_ctx.randrange(range); }
|
static inline uint64_t InsecureRandRange(uint64_t range) { return g_insecure_rand_ctx.randrange(range); }
|
||||||
static inline bool InsecureRandBool() { return insecure_rand_ctx.randbool(); }
|
static inline bool InsecureRandBool() { return g_insecure_rand_ctx.randbool(); }
|
||||||
|
|
||||||
static constexpr CAmount CENT{1000000};
|
static constexpr CAmount CENT{1000000};
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ struct CConnmanTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
class PeerLogicValidation;
|
class PeerLogicValidation;
|
||||||
struct TestingSetup: public BasicTestingSetup {
|
struct TestingSetup : public BasicTestingSetup {
|
||||||
boost::thread_group threadGroup;
|
boost::thread_group threadGroup;
|
||||||
CConnman* connman;
|
CConnman* connman;
|
||||||
CScheduler scheduler;
|
CScheduler scheduler;
|
||||||
|
|
Loading…
Reference in a new issue