| 75 | } |
| 76 | |
| 77 | TestingSetup::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 | |
| 113 | TestingSetup::~TestingSetup() |
| 114 | { |
nothing calls this directly
no test coverage detected