@@ -50,83 +50,83 @@ extern void noui_connect();
5050
5151BasicTestingSetup::BasicTestingSetup (const std::string& chainName)
5252{
53- SHA256AutoDetect ();
54- RandomInit ();
55- ECC_Start ();
56- BLSInit ();
57- SetupEnvironment ();
58- SetupNetworking ();
59- InitSignatureCache ();
60- InitScriptExecutionCache ();
61- CPrivateSend::InitStandardDenominations ();
62- fPrintToDebugLog = false ; // don't want to write to debug.log file
63- fCheckBlockIndex = true ;
64- SelectParams (chainName);
65- evoDb = new CEvoDB (1 << 20 , true , true );
66- deterministicMNManager = new CDeterministicMNManager (*evoDb);
67- noui_connect ();
53+ SHA256AutoDetect ();
54+ RandomInit ();
55+ ECC_Start ();
56+ BLSInit ();
57+ SetupEnvironment ();
58+ SetupNetworking ();
59+ InitSignatureCache ();
60+ InitScriptExecutionCache ();
61+ CPrivateSend::InitStandardDenominations ();
62+ fPrintToDebugLog = false ; // don't want to write to debug.log file
63+ fCheckBlockIndex = true ;
64+ SelectParams (chainName);
65+ evoDb = new CEvoDB (1 << 20 , true , true );
66+ deterministicMNManager = new CDeterministicMNManager (*evoDb);
67+ noui_connect ();
6868}
6969
7070BasicTestingSetup::~BasicTestingSetup ()
7171{
72- delete deterministicMNManager;
73- delete evoDb;
72+ delete deterministicMNManager;
73+ delete evoDb;
7474
75- ECC_Stop ();
75+ ECC_Stop ();
7676}
7777
7878TestingSetup::TestingSetup (const std::string& chainName) : BasicTestingSetup(chainName)
7979{
8080 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- RegisterAllCoreRPCCommands (tableRPC);
84- ClearDatadirCache ();
85- pathTemp = fs::temp_directory_path () / strprintf (" test_dash_%lu_%i" , (unsigned long )GetTime (), (int )(InsecureRandRange (100000 )));
86- fs::create_directories (pathTemp);
87- gArgs .ForceSetArg (" -datadir" , pathTemp.string ());
88-
89- // Note that because we don't bother running a scheduler thread here,
90- // callbacks via CValidationInterface are unreliable, but that's OK,
91- // our unit tests aren't testing multiple parts of the code at once.
92- GetMainSignals ().RegisterBackgroundSignalScheduler (scheduler);
93- mempool.setSanityCheck (1.0 );
94- g_connman = std::unique_ptr<CConnman>(new CConnman (0x1337 , 0x1337 )); // Deterministic randomness for tests.
95- connman = g_connman.get ();
96- pblocktree = new CBlockTreeDB (1 << 20 , true );
97- pcoinsdbview = new CCoinsViewDB (1 << 23 , true );
98- llmq::InitLLMQSystem (*evoDb, nullptr , true );
99- pcoinsTip = new CCoinsViewCache (pcoinsdbview);
100- if (!LoadGenesisBlock (chainparams)) {
101- throw std::runtime_error (" LoadGenesisBlock failed." );
102- }
103- {
104- CValidationState state;
105- if (!ActivateBestChain (state, chainparams)) {
106- throw std::runtime_error (" ActivateBestChain failed." );
107- }
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+ RegisterAllCoreRPCCommands (tableRPC);
84+ ClearDatadirCache ();
85+ pathTemp = fs::temp_directory_path () / strprintf (" test_dash_%lu_%i" , (unsigned long ) GetTime (), (int ) (InsecureRandRange (100000 )));
86+ fs::create_directories (pathTemp);
87+ gArgs .ForceSetArg (" -datadir" , pathTemp.string ());
88+
89+ // Note that because we don't bother running a scheduler thread here,
90+ // callbacks via CValidationInterface are unreliable, but that's OK,
91+ // our unit tests aren't testing multiple parts of the code at once.
92+ GetMainSignals ().RegisterBackgroundSignalScheduler (scheduler);
93+ mempool.setSanityCheck (1.0 );
94+ g_connman = std::unique_ptr<CConnman>(new CConnman (0x1337 , 0x1337 )); // Deterministic randomness for tests.
95+ connman = g_connman.get ();
96+ pblocktree = new CBlockTreeDB (1 << 20 , true );
97+ pcoinsdbview = new CCoinsViewDB (1 << 23 , true );
98+ llmq::InitLLMQSystem (*evoDb, nullptr , true );
99+ pcoinsTip = new CCoinsViewCache (pcoinsdbview);
100+ if (!LoadGenesisBlock (chainparams)) {
101+ throw std::runtime_error (" LoadGenesisBlock failed." );
102+ }
103+ {
104+ CValidationState state;
105+ if (!ActivateBestChain (state, chainparams)) {
106+ throw std::runtime_error (" ActivateBestChain failed." );
108107 }
109- nScriptCheckThreads = 3 ;
110- for (int i=0 ; i < nScriptCheckThreads-1 ; i++)
111- threadGroup.create_thread (&ThreadScriptCheck);
112- peerLogic.reset (new PeerLogicValidation (connman, scheduler));
108+ }
109+ nScriptCheckThreads = 3 ;
110+ for (int i = 0 ; i < nScriptCheckThreads - 1 ; i++)
111+ threadGroup.create_thread (&ThreadScriptCheck);
112+ peerLogic.reset (new PeerLogicValidation (connman, scheduler));
113113}
114114
115115TestingSetup::~TestingSetup ()
116116{
117- llmq::InterruptLLMQSystem ();
118- threadGroup.interrupt_all ();
119- threadGroup.join_all ();
120- GetMainSignals ().FlushBackgroundCallbacks ();
121- GetMainSignals ().UnregisterBackgroundSignalScheduler ();
122- g_connman.reset ();
123- peerLogic.reset ();
124- UnloadBlockIndex ();
125- delete pcoinsTip;
126- llmq::DestroyLLMQSystem ();
127- delete pcoinsdbview;
128- delete pblocktree;
129- fs::remove_all (pathTemp);
117+ llmq::InterruptLLMQSystem ();
118+ threadGroup.interrupt_all ();
119+ threadGroup.join_all ();
120+ GetMainSignals ().FlushBackgroundCallbacks ();
121+ GetMainSignals ().UnregisterBackgroundSignalScheduler ();
122+ g_connman.reset ();
123+ peerLogic.reset ();
124+ UnloadBlockIndex ();
125+ delete pcoinsTip;
126+ llmq::DestroyLLMQSystem ();
127+ delete pcoinsdbview;
128+ delete pblocktree;
129+ fs::remove_all (pathTemp);
130130}
131131
132132TestChainSetup::TestChainSetup (int blockCount) : TestingSetup(CBaseChainParams::REGTEST)
0 commit comments