| 89 | } |
| 90 | |
| 91 | BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::string& fedpegscript, const std::vector<const char*>& extra_args) |
| 92 | : m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()}, |
| 93 | m_args{} |
| 94 | { |
| 95 | // Hack to allow testing of fedpeg args |
| 96 | if (!fedpegscript.empty()) { |
| 97 | gArgs.SoftSetArg("-fedpegscript", fedpegscript); |
| 98 | gArgs.SoftSetBoolArg("-con_has_parent_chain", true); |
| 99 | gArgs.SoftSetBoolArg("-validatepegin", false); |
| 100 | } |
| 101 | |
| 102 | m_node.args = &gArgs; |
| 103 | std::vector<const char*> arguments = Cat( |
| 104 | { |
| 105 | "dummy", |
| 106 | "-printtoconsole=0", |
| 107 | "-logsourcelocations", |
| 108 | "-logtimemicros", |
| 109 | "-logthreadnames", |
| 110 | "-debug", |
| 111 | "-debugexclude=libevent", |
| 112 | "-debugexclude=leveldb", |
| 113 | }, |
| 114 | extra_args); |
| 115 | if (G_TEST_COMMAND_LINE_ARGUMENTS) { |
| 116 | arguments = Cat(arguments, G_TEST_COMMAND_LINE_ARGUMENTS()); |
| 117 | } |
| 118 | util::ThreadRename("test"); |
| 119 | fs::create_directories(m_path_root); |
| 120 | m_args.ForceSetArg("-datadir", fs::PathToString(m_path_root)); |
| 121 | gArgs.ForceSetArg("-datadir", fs::PathToString(m_path_root)); |
| 122 | gArgs.ClearPathCache(); |
| 123 | { |
| 124 | SetupServerArgs(*m_node.args); |
| 125 | std::string error; |
| 126 | if (!m_node.args->ParseParameters(arguments.size(), arguments.data(), error)) { |
| 127 | m_node.args->ClearArgs(); |
| 128 | throw std::runtime_error{error}; |
| 129 | } |
| 130 | } |
| 131 | SelectParams(chainName); |
| 132 | SeedInsecureRand(); |
| 133 | if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN); |
| 134 | InitLogging(*m_node.args); |
| 135 | AppInitParameterInteraction(*m_node.args); |
| 136 | LogInstance().StartLogging(); |
| 137 | SHA256AutoDetect(); |
| 138 | ECC_Start(); |
| 139 | SetupEnvironment(); |
| 140 | SetupNetworking(); |
| 141 | InitSignatureCache(); |
| 142 | InitScriptExecutionCache(); |
| 143 | InitRangeproofCache(); |
| 144 | InitSurjectionproofCache(); |
| 145 | m_node.chain = interfaces::MakeChain(m_node); |
| 146 | fCheckBlockIndex = true; |
| 147 | |
| 148 | // ELEMENTS: |
nothing calls this directly
no test coverage detected