Changeset View
Changeset View
Standalone View
Standalone View
src/test/test_bitcoin.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | TestingSetup::TestingSetup(const std::string &chainName) | ||||
ClearDatadirCache(); | ClearDatadirCache(); | ||||
pathTemp = fs::temp_directory_path() / | pathTemp = fs::temp_directory_path() / | ||||
strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), | strprintf("test_bitcoin_%lu_%i", (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, | // We have to run a scheduler thread to prevent ActivateBestChain | ||||
// callbacks via CValidationInterface are unreliable, but that's OK, | // from blocking due to queue overrun. | ||||
// our unit tests aren't testing multiple parts of the code at once. | threadGroup.create_thread( | ||||
boost::bind(&CScheduler::serviceQueue, &scheduler)); | |||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); | GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); | ||||
g_mempool.setSanityCheck(1.0); | g_mempool.setSanityCheck(1.0); | ||||
pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | ||||
pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); | pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); | ||||
pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); | pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); | ||||
if (!LoadGenesisBlock(chainparams)) { | if (!LoadGenesisBlock(chainparams)) { | ||||
throw std::runtime_error("InitBlockIndex failed."); | throw std::runtime_error("InitBlockIndex failed."); | ||||
▲ Show 20 Lines • Show All 175 Lines • Show Last 20 Lines |