Changeset View
Changeset View
Standalone View
Standalone View
src/test/setup_common.h
// Copyright (c) 2015-2019 The Bitcoin Core developers | // Copyright (c) 2015-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_TEST_SETUP_COMMON_H | #ifndef BITCOIN_TEST_SETUP_COMMON_H | ||||
#define BITCOIN_TEST_SETUP_COMMON_H | #define BITCOIN_TEST_SETUP_COMMON_H | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <chainparamsbase.h> | #include <chainparamsbase.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <scheduler.h> | #include <scheduler.h> | ||||
#include <util/system.h> | |||||
/** | /** | ||||
* Version of Boost::test prior to 1.64 have issues when dealing with nullptr_t. | * Version of Boost::test prior to 1.64 have issues when dealing with nullptr_t. | ||||
* In order to work around this, we ensure that the null pointers are typed in a | * In order to work around this, we ensure that the null pointers are typed in a | ||||
* way that Boost will like better. | * way that Boost will like better. | ||||
* | * | ||||
* TODO: Use nullptr directly once the minimum version of boost is 1.64 or more. | * TODO: Use nullptr directly once the minimum version of boost is 1.64 or more. | ||||
*/ | */ | ||||
Show All 32 Lines | |||||
static inline bool InsecureRandBool() { | static inline bool InsecureRandBool() { | ||||
return g_insecure_rand_ctx.randbool(); | return g_insecure_rand_ctx.randbool(); | ||||
} | } | ||||
static constexpr Amount CENT(COIN / 100); | static constexpr Amount CENT(COIN / 100); | ||||
/** | /** | ||||
* Basic testing setup. | * Basic testing setup. | ||||
* This just configures logging and chain parameters. | * This just configures logging, data dir and chain parameters. | ||||
*/ | */ | ||||
struct BasicTestingSetup { | struct BasicTestingSetup { | ||||
ECCVerifyHandle globalVerifyHandle; | ECCVerifyHandle globalVerifyHandle; | ||||
explicit BasicTestingSetup( | explicit BasicTestingSetup( | ||||
const std::string &chainName = CBaseChainParams::MAIN); | const std::string &chainName = CBaseChainParams::MAIN); | ||||
~BasicTestingSetup(); | ~BasicTestingSetup(); | ||||
fs::path SetDataDir(const std::string &name); | |||||
private: | private: | ||||
const fs::path m_path_root; | const fs::path m_path_root; | ||||
}; | }; | ||||
/** | /** | ||||
* Testing setup that configures a complete environment. | * Testing setup that configures a complete environment. | ||||
* Included are data directory, coins database, script check threads setup. | * Included are coins database, script check threads setup. | ||||
*/ | */ | ||||
struct TestingSetup : public BasicTestingSetup { | struct TestingSetup : public BasicTestingSetup { | ||||
boost::thread_group threadGroup; | boost::thread_group threadGroup; | ||||
CScheduler scheduler; | CScheduler scheduler; | ||||
explicit TestingSetup( | explicit TestingSetup( | ||||
const std::string &chainName = CBaseChainParams::MAIN); | const std::string &chainName = CBaseChainParams::MAIN); | ||||
~TestingSetup(); | ~TestingSetup(); | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |