Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.cpp
Show All 14 Lines | |||||
#include <key.h> | #include <key.h> | ||||
#include <logging.h> | #include <logging.h> | ||||
#include <miner.h> | #include <miner.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <noui.h> | #include <noui.h> | ||||
#include <pow.h> | #include <pow.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <rpc/blockchain.h> | |||||
#include <rpc/register.h> | #include <rpc/register.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <script/script_error.h> | #include <script/script_error.h> | ||||
#include <script/scriptcache.h> | #include <script/scriptcache.h> | ||||
#include <script/sigcache.h> | #include <script/sigcache.h> | ||||
#include <streams.h> | #include <streams.h> | ||||
#include <txdb.h> | #include <txdb.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | BasicTestingSetup::~BasicTestingSetup() { | ||||
LogInstance().DisconnectTestLogger(); | LogInstance().DisconnectTestLogger(); | ||||
fs::remove_all(m_path_root); | fs::remove_all(m_path_root); | ||||
ECC_Stop(); | ECC_Stop(); | ||||
} | } | ||||
TestingSetup::TestingSetup(const std::string &chainName) | TestingSetup::TestingSetup(const std::string &chainName) | ||||
: BasicTestingSetup(chainName) { | : BasicTestingSetup(chainName) { | ||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
g_rpc_node = &m_node; | |||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
// Ideally we'd move all the RPC tests to the functional testing framework | // Ideally we'd move all the RPC tests to the functional testing framework | ||||
// instead of unit tests, but for now we need these here. | // instead of unit tests, but for now we need these here. | ||||
RPCServer rpcServer; | RPCServer rpcServer; | ||||
RegisterAllRPCCommands(config, rpcServer, tableRPC); | RegisterAllRPCCommands(config, rpcServer, tableRPC); | ||||
/** | /** | ||||
Show All 25 Lines | if (!LoadGenesisBlock(chainparams)) { | ||||
FormatStateMessage(state))); | FormatStateMessage(state))); | ||||
} | } | ||||
} | } | ||||
nScriptCheckThreads = 3; | nScriptCheckThreads = 3; | ||||
for (int i = 0; i < nScriptCheckThreads - 1; i++) { | for (int i = 0; i < nScriptCheckThreads - 1; i++) { | ||||
threadGroup.create_thread([i]() { return ThreadScriptCheck(i); }); | threadGroup.create_thread([i]() { return ThreadScriptCheck(i); }); | ||||
} | } | ||||
g_banman = | m_node.banman = | ||||
std::make_unique<BanMan>(GetDataDir() / "banlist.dat", chainparams, | std::make_unique<BanMan>(GetDataDir() / "banlist.dat", chainparams, | ||||
nullptr, DEFAULT_MISBEHAVING_BANTIME); | nullptr, DEFAULT_MISBEHAVING_BANTIME); | ||||
// Deterministic randomness for tests. | // Deterministic randomness for tests. | ||||
g_connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | m_node.connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | ||||
} | } | ||||
TestingSetup::~TestingSetup() { | TestingSetup::~TestingSetup() { | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
GetMainSignals().FlushBackgroundCallbacks(); | GetMainSignals().FlushBackgroundCallbacks(); | ||||
GetMainSignals().UnregisterBackgroundSignalScheduler(); | GetMainSignals().UnregisterBackgroundSignalScheduler(); | ||||
g_connman.reset(); | g_rpc_node = nullptr; | ||||
g_banman.reset(); | m_node.connman.reset(); | ||||
m_node.banman.reset(); | |||||
UnloadBlockIndex(); | UnloadBlockIndex(); | ||||
pcoinsTip.reset(); | pcoinsTip.reset(); | ||||
pcoinsdbview.reset(); | pcoinsdbview.reset(); | ||||
pblocktree.reset(); | pblocktree.reset(); | ||||
} | } | ||||
TestChain100Setup::TestChain100Setup() { | TestChain100Setup::TestChain100Setup() { | ||||
// Generate a 100-block chain: | // Generate a 100-block chain: | ||||
▲ Show 20 Lines • Show All 172 Lines • Show Last 20 Lines |