MCPcopy Create free account
hub / github.com/ElementsProject/elements / TestingSetup

Method TestingSetup

src/test/util/setup_common.cpp:214–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214TestingSetup::TestingSetup(const std::string& chainName, const std::string& fedpegscript, const std::vector<const char*>& extra_args)
215 : ChainTestingSetup(chainName, fedpegscript, extra_args)
216{
217 const CChainParams& chainparams = Params();
218 // Ideally we'd move all the RPC tests to the functional testing framework
219 // instead of unit tests, but for now we need these here.
220 RegisterAllCoreRPCCommands(tableRPC);
221
222 auto maybe_load_error = LoadChainstate(fReindex.load(),
223 *Assert(m_node.chainman.get()),
224 Assert(m_node.mempool.get()),
225 fPruneMode,
226 chainparams.GetConsensus(),
227 m_args.GetBoolArg("-reindex-chainstate", false),
228 m_cache_sizes.block_tree_db,
229 m_cache_sizes.coins_db,
230 m_cache_sizes.coins,
231 /*block_tree_db_in_memory=*/true,
232 /*coins_db_in_memory=*/true);
233 assert(!maybe_load_error.has_value());
234
235 auto maybe_verify_error = VerifyLoadedChainstate(
236 *Assert(m_node.chainman),
237 fReindex.load(),
238 m_args.GetBoolArg("-reindex-chainstate", false),
239 chainparams.GetConsensus(),
240 m_args.GetIntArg("-checkblocks", DEFAULT_CHECKBLOCKS),
241 m_args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
242 /*get_unix_time_seconds=*/static_cast<int64_t(*)()>(GetTime));
243 assert(!maybe_verify_error.has_value());
244
245 BlockValidationState state;
246 if (!m_node.chainman->ActiveChainstate().ActivateBestChain(state)) {
247 throw std::runtime_error(strprintf("ActivateBestChain failed. (%s)", state.ToString()));
248 }
249
250 m_node.addrman = std::make_unique<AddrMan>(/*asmap=*/std::vector<bool>(),
251 /*deterministic=*/false,
252 m_node.args->GetIntArg("-checkaddrman", 0));
253 m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
254 m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
255 m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman,
256 m_node.banman.get(), *m_node.chainman,
257 *m_node.mempool, false);
258 {
259 CConnman::Options options;
260 options.m_msgproc = m_node.peerman.get();
261 m_node.connman->Init(options);
262 }
263}
264
265TestChain100Setup::TestChain100Setup(const std::vector<const char*>& extra_args)
266 : TestingSetup{CBaseChainParams::REGTEST, "", extra_args} // ELEMENTS: added empty fedpegscript here

Callers

nothing calls this directly

Calls 11

LoadChainstateFunction · 0.85
VerifyLoadedChainstateFunction · 0.85
GetBoolArgMethod · 0.80
GetIntArgMethod · 0.80
ActivateBestChainMethod · 0.80
ParamsClass · 0.50
loadMethod · 0.45
getMethod · 0.45
ToStringMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected