1 // Copyright (c) 2011-2013 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #define BOOST_TEST_MODULE Bitcoin Test Suite
7 #include "test_bitcoin.h"
9 #include "crypto/common.h"
14 #include "chainparamsbase.h"
16 #include "ui_interface.h"
19 #include "wallet/db.h"
20 #include "wallet/wallet.h"
23 #include <boost/filesystem.hpp>
24 #include <boost/test/unit_test.hpp>
25 #include <boost/thread.hpp>
27 CClientUIInterface uiInterface; // Declared but not defined in ui_interface.h
29 ZCJoinSplit *pzcashParams;
31 extern bool fPrintToConsole;
32 extern void noui_connect();
34 BasicTestingSetup::BasicTestingSetup()
36 assert(init_and_check_sodium() != -1);
38 pzcashParams = ZCJoinSplit::Unopened();
40 fPrintToDebugLog = false; // don't want to write to debug.log file
41 fCheckBlockIndex = true;
42 SelectParams(CBaseChainParams::MAIN);
44 BasicTestingSetup::~BasicTestingSetup()
50 TestingSetup::TestingSetup()
56 pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
57 boost::filesystem::create_directories(pathTemp);
58 mapArgs["-datadir"] = pathTemp.string();
59 pblocktree = new CBlockTreeDB(1 << 20, true);
60 pcoinsdbview = new CCoinsViewDB(1 << 23, true);
61 pcoinsTip = new CCoinsViewCache(pcoinsdbview);
65 pwalletMain = new CWallet("wallet.dat");
66 pwalletMain->LoadWallet(fFirstRun);
67 RegisterValidationInterface(pwalletMain);
69 nScriptCheckThreads = 3;
70 for (int i=0; i < nScriptCheckThreads-1; i++)
71 threadGroup.create_thread(&ThreadScriptCheck);
72 RegisterNodeSignals(GetNodeSignals());
75 TestingSetup::~TestingSetup()
77 UnregisterNodeSignals(GetNodeSignals());
78 threadGroup.interrupt_all();
79 threadGroup.join_all();
81 UnregisterValidationInterface(pwalletMain);
93 boost::filesystem::remove_all(pathTemp);
96 void Shutdown(void* parg)
106 bool ShutdownRequested()