merge bitcoin#18571: Disable debug log file

This commit is contained in:
Kittywhiskers Van Gogh 2022-05-30 01:19:04 +05:30
parent 3b3a41efe5
commit 0af1a5a969
9 changed files with 48 additions and 13 deletions

View File

@ -61,6 +61,8 @@ int main(int argc, char** argv)
args.output_csv = gArgs.GetArg("-output_csv", "");
args.output_json = gArgs.GetArg("-output_json", "");
gArgs.ClearArgs(); // gArgs no longer needed. Clear it here to avoid interactions with the testing setup in the benches
benchmark::BenchRunner::RunAll(args);
return EXIT_SUCCESS;

View File

@ -55,7 +55,7 @@ static bool AppInit(int argc, char* argv[])
// Parameters
//
// If Qt is used, parameters/dash.conf are parsed in qt/dash.cpp's main()
SetupServerArgs();
SetupServerArgs(node);
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));

View File

@ -395,6 +395,7 @@ void Shutdown(NodeContext& node)
// Shutdown part 2: delete wallet instance
globalVerifyHandle.reset();
ECC_Stop();
node.args = nullptr;
node.mempool = nullptr;
node.chainman = nullptr;
node.scheduler.reset();
@ -465,8 +466,11 @@ std::string GetSupportedSocketEventsStr()
return strSupportedModes;
}
void SetupServerArgs()
void SetupServerArgs(NodeContext& node)
{
assert(!node.args);
node.args = &gArgs;
const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN);
const auto testnetBaseParams = CreateBaseChainParams(CBaseChainParams::TESTNET);
const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST);

View File

@ -61,9 +61,9 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
void PrepareShutdown(NodeContext& node);
/**
* Setup the arguments for gArgs
* Register all arguments with the ArgsManager
*/
void SetupServerArgs();
void SetupServerArgs(NodeContext& node);
/** Returns licensing information (for -version) */
std::string LicenseInfo();

View File

@ -217,7 +217,7 @@ public:
void startShutdown() override { StartShutdown(); }
bool shutdownRequested() override { return ShutdownRequested(); }
void mapPort(bool use_upnp, bool use_natpmp) override { StartMapPort(use_upnp, use_natpmp); }
void setupServerArgs() override { return SetupServerArgs(); }
void setupServerArgs() override { return SetupServerArgs(m_context); }
bool getProxy(Network net, proxyType& proxy_info) override { return GetProxy(net, proxy_info); }
size_t getNodeCount(CConnman::NumConnections flags) override
{

View File

@ -10,6 +10,7 @@
#include <memory>
#include <vector>
class ArgsManager;
class BanMan;
class CConnman;
class CScheduler;
@ -37,6 +38,7 @@ struct NodeContext {
std::unique_ptr<PeerLogicValidation> peer_logic;
ChainstateManager* chainman{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
std::unique_ptr<BanMan> banman;
ArgsManager* args{nullptr}; // Currently a raw pointer because the memory is not managed by this struct
std::unique_ptr<interfaces::Chain> chain;
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
std::unique_ptr<CScheduler> scheduler;

View File

@ -57,12 +57,17 @@ const std::map<std::string, std::set<std::string>> EXPECTED_DESERIALIZATION_EXCE
{"Unknown transaction optional data: iostream error", {"block", "blocktxn", "cmpctblock", "tx"}},
};
const RegTestingSetup* g_setup;
const TestingSetup* g_setup;
} // namespace
void initialize()
{
static RegTestingSetup setup{};
static TestingSetup setup{
CBaseChainParams::REGTEST,
{
"-nodebuglogfile",
},
};
g_setup = &setup;
for (int i = 0; i < 2 * COINBASE_MATURITY; i++) {

View File

@ -27,6 +27,7 @@
#include <util/strencodings.h>
#include <util/time.h>
#include <util/translation.h>
#include <util/vector.h>
#include <validation.h>
#include <validationinterface.h>
@ -72,17 +73,34 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
return os;
}
BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
BasicTestingSetup::BasicTestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
: m_path_root{fs::temp_directory_path() / "test_common_" PACKAGE_NAME / g_insecure_rand_ctx_temp_path.rand256().ToString()}
{
const std::vector<const char*> arguments = Cat(
{
"dummy",
"-printtoconsole=0",
"-logtimemicros",
"-debug",
"-debugexclude=libevent",
"-debugexclude=leveldb",
},
extra_args);
fs::create_directories(m_path_root);
gArgs.ForceSetArg("-datadir", m_path_root.string());
ClearDatadirCache();
{
SetupServerArgs(m_node);
std::string error;
const bool success{m_node.args->ParseParameters(arguments.size(), arguments.data(), error)};
assert(success);
assert(error.empty());
}
SelectParams(chainName);
SeedInsecureRand();
gArgs.ForceSetArg("-printtoconsole", "0");
if (G_TEST_LOG_FUN) LogInstance().PushBackCallback(G_TEST_LOG_FUN);
InitLogging();
AppInitParameterInteraction();
LogInstance().StartLogging();
SHA256AutoDetect();
ECC_Start();
@ -112,10 +130,12 @@ BasicTestingSetup::~BasicTestingSetup()
LogInstance().DisconnectTestLogger();
fs::remove_all(m_path_root);
gArgs.ClearArgs();
ECC_Stop();
}
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const char*>& extra_args)
: BasicTestingSetup(chainName, extra_args)
{
const CChainParams& chainparams = Params();
// Ideally we'd move all the RPC tests to the functional testing framework
@ -177,6 +197,7 @@ TestingSetup::~TestingSetup()
m_node.banman.reset();
UnloadBlockIndex(m_node.mempool);
m_node.mempool = nullptr;
m_node.args = nullptr;
m_node.scheduler.reset();
llmq::DestroyLLMQSystem();
m_node.chainman->Reset();

View File

@ -74,9 +74,11 @@ static constexpr CAmount CENT{1000000};
*/
struct BasicTestingSetup {
ECCVerifyHandle globalVerifyHandle;
NodeContext m_node;
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
~BasicTestingSetup();
private:
std::unique_ptr<CConnman> connman;
const fs::path m_path_root;
@ -86,10 +88,9 @@ private:
* Included are coins database, script check threads setup.
*/
struct TestingSetup : public BasicTestingSetup {
NodeContext m_node;
boost::thread_group threadGroup;
explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN, const std::vector<const char*>& extra_args = {});
~TestingSetup();
};