File tree Expand file tree Collapse file tree 5 files changed +19
-1
lines changed
Expand file tree Collapse file tree 5 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,14 @@ bool BCLog::Logger::StartLogging()
7575 return true ;
7676}
7777
78+ void BCLog::Logger::DisconnectTestLogger ()
79+ {
80+ std::lock_guard<std::mutex> scoped_lock (m_cs);
81+ m_buffering = true ;
82+ if (m_fileout != nullptr ) fclose (m_fileout);
83+ m_fileout = nullptr ;
84+ }
85+
7886void BCLog::Logger::EnableCategory (BCLog::LogFlags flag)
7987{
8088 m_categories |= flag;
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ namespace BCLog {
100100
101101 /* * Start logging (and flush all buffered messages) */
102102 bool StartLogging ();
103+ /* * Only for testing */
104+ void DisconnectTestLogger ();
103105
104106 void ShrinkDebugFile ();
105107
Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ void AppTests::appTests()
6464#endif
6565
6666 ECC_Stop (); // Already started by the common test setup, so stop it to avoid interference
67+ LogInstance ().DisconnectTestLogger ();
68+
6769 m_app.parameterSetup ();
6870 m_app.createOptionsModel (true /* reset settings */ );
6971 QScopedPointer<const NetworkStyle> style (
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ void RPCNestedTests::rpcNestedTests()
3535 tableRPC.appendCommand (" rpcNestedTest" , &vRPCCommands[0 ]);
3636 // mempool.setSanityCheck(1.0);
3737
38+ LogInstance ().DisconnectTestLogger (); // Already started by the common test setup, so stop it to avoid interference
3839 TestingSetup test;
3940
4041 if (RPCIsInWarmup (nullptr )) SetRPCWarmupFinished ();
Original file line number Diff line number Diff line change 1010#include < consensus/params.h>
1111#include < consensus/validation.h>
1212#include < crypto/sha256.h>
13+ #include < init.h>
1314#include < miner.h>
1415#include < net_processing.h>
1516#include < noui.h>
@@ -37,14 +38,17 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
3738 fs::create_directories (m_path_root);
3839 gArgs .ForceSetArg (" -datadir" , m_path_root.string ());
3940 ClearDatadirCache ();
41+ SelectParams (chainName);
42+ gArgs .ForceSetArg (" -printtoconsole" , " 0" );
43+ InitLogging ();
44+ LogInstance ().StartLogging ();
4045 SHA256AutoDetect ();
4146 ECC_Start ();
4247 SetupEnvironment ();
4348 SetupNetworking ();
4449 InitSignatureCache ();
4550 InitScriptExecutionCache ();
4651 fCheckBlockIndex = true ;
47- SelectParams (chainName);
4852 static bool noui_connected = false ;
4953 if (!noui_connected) {
5054 noui_connect ();
@@ -54,6 +58,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
5458
5559BasicTestingSetup::~BasicTestingSetup ()
5660{
61+ LogInstance ().DisconnectTestLogger ();
5762 fs::remove_all (m_path_root);
5863 ECC_Stop ();
5964}
You can’t perform that action at this time.
0 commit comments