Changeset View
Changeset View
Standalone View
Standalone View
src/test/test_bitcoin.cpp
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | TestingSetup::TestingSetup(const std::string &chainName) | ||||
RPCServer rpcServer; | RPCServer rpcServer; | ||||
RegisterAllRPCCommands(config, rpcServer, tableRPC); | RegisterAllRPCCommands(config, rpcServer, tableRPC); | ||||
ClearDatadirCache(); | ClearDatadirCache(); | ||||
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", | pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", | ||||
(unsigned long)GetTime(), | (unsigned long)GetTime(), | ||||
(int)(InsecureRandRange(100000))); | (int)(InsecureRandRange(100000))); | ||||
fs::create_directories(pathTemp); | fs::create_directories(pathTemp); | ||||
gArgs.ForceSetArg("-datadir", pathTemp.string()); | gArgs.ForceSetArg("-datadir", pathTemp.string()); | ||||
// Note that because we don't bother running a scheduler thread here, | |||||
// callbacks via CValidationInterface are unreliable, but that's OK, | |||||
// our unit tests aren't testing multiple parts of the code at once. | |||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); | |||||
mempool.setSanityCheck(1.0); | mempool.setSanityCheck(1.0); | ||||
pblocktree = new CBlockTreeDB(1 << 20, true); | pblocktree = new CBlockTreeDB(1 << 20, true); | ||||
pcoinsdbview = new CCoinsViewDB(1 << 23, true); | pcoinsdbview = new CCoinsViewDB(1 << 23, true); | ||||
pcoinsTip = new CCoinsViewCache(pcoinsdbview); | pcoinsTip = new CCoinsViewCache(pcoinsdbview); | ||||
if (!InitBlockIndex(config)) { | if (!InitBlockIndex(config)) { | ||||
throw std::runtime_error("InitBlockIndex failed."); | throw std::runtime_error("InitBlockIndex failed."); | ||||
} | } | ||||
{ | { | ||||
Show All 11 Lines | TestingSetup::TestingSetup(const std::string &chainName) | ||||
g_connman = std::unique_ptr<CConnman>(new CConnman(config, 0x1337, 0x1337)); | g_connman = std::unique_ptr<CConnman>(new CConnman(config, 0x1337, 0x1337)); | ||||
connman = g_connman.get(); | connman = g_connman.get(); | ||||
peerLogic.reset(new PeerLogicValidation(connman, scheduler)); | peerLogic.reset(new PeerLogicValidation(connman, scheduler)); | ||||
} | } | ||||
TestingSetup::~TestingSetup() { | TestingSetup::~TestingSetup() { | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
GetMainSignals().FlushBackgroundCallbacks(); | |||||
GetMainSignals().UnregisterBackgroundSignalScheduler(); | |||||
g_connman.reset(); | g_connman.reset(); | ||||
peerLogic.reset(); | peerLogic.reset(); | ||||
UnloadBlockIndex(); | UnloadBlockIndex(); | ||||
delete pcoinsTip; | delete pcoinsTip; | ||||
delete pcoinsdbview; | delete pcoinsdbview; | ||||
delete pblocktree; | delete pblocktree; | ||||
fs::remove_all(pathTemp); | fs::remove_all(pathTemp); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |