MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / TestingSetup

Method TestingSetup

src/test/test_bitcoin.cpp:77–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
78{
79 SetDataDir("tempdir");
80 const CChainParams& chainparams = Params();
81 // Ideally we'd move all the RPC tests to the functional testing framework
82 // instead of unit tests, but for now we need these here.
83
84 RegisterAllCoreRPCCommands(tableRPC);
85 ClearDatadirCache();
86
87 // We have to run a scheduler thread to prevent ActivateBestChain
88 // from blocking due to queue overrun.
89 threadGroup.create_thread(boost::bind(&CScheduler::serviceQueue, &scheduler));
90 GetMainSignals().RegisterBackgroundSignalScheduler(scheduler);
91
92 mempool.setSanityCheck(1.0);
93 pblocktree.reset(new CBlockTreeDB(1 << 20, true));
94 pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true));
95 pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get()));
96 if (!LoadGenesisBlock(chainparams)) {
97 throw std::runtime_error("LoadGenesisBlock failed.");
98 }
99 {
100 CValidationState state;
101 if (!ActivateBestChain(state, chainparams)) {
102 throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", FormatStateMessage(state)));
103 }
104 }
105 nScriptCheckThreads = 3;
106 for (int i=0; i < nScriptCheckThreads-1; i++)
107 threadGroup.create_thread(&ThreadScriptCheck);
108 g_connman = std::unique_ptr<CConnman>(new CConnman(0x1337, 0x1337)); // Deterministic randomness for tests.
109 connman = g_connman.get();
110 peerLogic.reset(new PeerLogicValidation(connman, scheduler, /*enable_bip61=*/true));
111}
112
113TestingSetup::~TestingSetup()
114{

Callers

nothing calls this directly

Calls 11

SetDataDirFunction · 0.85
ClearDatadirCacheFunction · 0.85
LoadGenesisBlockFunction · 0.85
ActivateBestChainFunction · 0.85
FormatStateMessageFunction · 0.85
setSanityCheckMethod · 0.80
getMethod · 0.80
ParamsClass · 0.50
resetMethod · 0.45

Tested by

no test coverage detected