Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/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_UTIL_SETUP_COMMON_H | #ifndef BITCOIN_TEST_UTIL_SETUP_COMMON_H | ||||
#define BITCOIN_TEST_UTIL_SETUP_COMMON_H | #define BITCOIN_TEST_UTIL_SETUP_COMMON_H | ||||
#include <blockindex.h> | #include <blockindex.h> | ||||
#include <chainparamsbase.h> | #include <chainparamsbase.h> | ||||
#include <config.h> | |||||
#include <consensus/amount.h> | #include <consensus/amount.h> | ||||
#include <fs.h> | #include <fs.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <node/caches.h> | #include <node/caches.h> | ||||
#include <node/context.h> | #include <node/context.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <random.h> | #include <random.h> | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | |||||
* ChainstateManager gets initialized. Meant for testing ChainstateManager | * ChainstateManager gets initialized. Meant for testing ChainstateManager | ||||
* initialization behaviour. | * initialization behaviour. | ||||
*/ | */ | ||||
struct ChainTestingSetup : public BasicTestingSetup { | struct ChainTestingSetup : public BasicTestingSetup { | ||||
node::CacheSizes m_cache_sizes{}; | node::CacheSizes m_cache_sizes{}; | ||||
explicit ChainTestingSetup( | explicit ChainTestingSetup( | ||||
const std::string &chainName = CBaseChainParams::MAIN, | const std::string &chainName = CBaseChainParams::MAIN, | ||||
const std::vector<const char *> &extra_args = {}); | const std::vector<const char *> &extra_args = {}, | ||||
const Config &config = ::GetConfig()); | |||||
~ChainTestingSetup(); | ~ChainTestingSetup(); | ||||
}; | }; | ||||
/** | /** | ||||
* Testing setup that configures a complete environment. | * Testing setup that configures a complete environment. | ||||
*/ | */ | ||||
struct TestingSetup : public ChainTestingSetup { | struct TestingSetup : public ChainTestingSetup { | ||||
bool m_coins_db_in_memory{true}; | bool m_coins_db_in_memory{true}; | ||||
bool m_block_tree_db_in_memory{true}; | bool m_block_tree_db_in_memory{true}; | ||||
void LoadVerifyActivateChainstate(); | void LoadVerifyActivateChainstate(); | ||||
explicit TestingSetup(const std::string &chainName = CBaseChainParams::MAIN, | explicit TestingSetup(const std::string &chainName = CBaseChainParams::MAIN, | ||||
const std::vector<const char *> &extra_args = {}, | const std::vector<const char *> &extra_args = {}, | ||||
const bool coins_db_in_memory = true, | const bool coins_db_in_memory = true, | ||||
const bool block_tree_db_in_memory = true); | const bool block_tree_db_in_memory = true, | ||||
const Config &config = ::GetConfig()); | |||||
}; | }; | ||||
/** Identical to TestingSetup, but chain set to regtest */ | /** Identical to TestingSetup, but chain set to regtest */ | ||||
struct RegTestingSetup : public TestingSetup { | struct RegTestingSetup : public TestingSetup { | ||||
RegTestingSetup() : TestingSetup{CBaseChainParams::REGTEST} {} | RegTestingSetup() : TestingSetup{CBaseChainParams::REGTEST} {} | ||||
}; | }; | ||||
class CBlock; | class CBlock; | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |