Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/setup_common.cpp
Show All 9 Lines | |||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <consensus/validation.h> | #include <consensus/validation.h> | ||||
#include <crypto/sha256.h> | #include <crypto/sha256.h> | ||||
#include <init.h> | #include <init.h> | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <logging.h> | #include <logging.h> | ||||
#include <miner.h> | #include <miner.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <net_processing.h> | |||||
#include <noui.h> | #include <noui.h> | ||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <rpc/blockchain.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> | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
std::ostream &operator<<(std::ostream &os, const ScriptError &err) { | std::ostream &operator<<(std::ostream &os, const ScriptError &err) { | ||||
os << ScriptErrorString(err); | os << ScriptErrorString(err); | ||||
return os; | return os; | ||||
} | } | ||||
BasicTestingSetup::BasicTestingSetup(const std::string &chainName) | BasicTestingSetup::BasicTestingSetup(const std::string &chainName) | ||||
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / | : m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / | ||||
std::to_string(g_insecure_rand_ctx_temp_path.rand32())} { | g_insecure_rand_ctx_temp_path.rand256().ToString()} { | ||||
SetMockTime(0); | SetMockTime(0); | ||||
fs::create_directories(m_path_root); | fs::create_directories(m_path_root); | ||||
gArgs.ForceSetArg("-datadir", m_path_root.string()); | gArgs.ForceSetArg("-datadir", m_path_root.string()); | ||||
ClearDatadirCache(); | ClearDatadirCache(); | ||||
SelectParams(chainName); | SelectParams(chainName); | ||||
SeedInsecureRand(); | SeedInsecureRand(); | ||||
gArgs.ForceSetArg("-printtoconsole", "0"); | gArgs.ForceSetArg("-printtoconsole", "0"); | ||||
InitLogging(); | InitLogging(); | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | TestingSetup::TestingSetup(const std::string &chainName) | ||||
m_node.mempool = &::g_mempool; | m_node.mempool = &::g_mempool; | ||||
m_node.mempool->setSanityCheck(1.0); | m_node.mempool->setSanityCheck(1.0); | ||||
m_node.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. | ||||
m_node.connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | m_node.connman = std::make_unique<CConnman>(config, 0x1337, 0x1337); | ||||
m_node.peer_logic = std::make_unique<PeerLogicValidation>( | |||||
m_node.connman.get(), m_node.banman.get(), *m_node.scheduler); | |||||
} | } | ||||
TestingSetup::~TestingSetup() { | TestingSetup::~TestingSetup() { | ||||
if (m_node.scheduler) { | if (m_node.scheduler) { | ||||
m_node.scheduler->stop(); | m_node.scheduler->stop(); | ||||
} | } | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
▲ Show 20 Lines • Show All 185 Lines • Show Last 20 Lines |