Changeset View
Changeset View
Standalone View
Standalone View
src/test/test_bitcoin.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | TestingSetup::TestingSetup(const std::string &chainName) | ||||
gArgs.ForceSetArg("-datadir", pathTemp.string()); | gArgs.ForceSetArg("-datadir", pathTemp.string()); | ||||
// Note that because we don't bother running a scheduler thread here, | // Note that because we don't bother running a scheduler thread here, | ||||
// callbacks via CValidationInterface are unreliable, but that's OK, | // callbacks via CValidationInterface are unreliable, but that's OK, | ||||
// our unit tests aren't testing multiple parts of the code at once. | // our unit tests aren't testing multiple parts of the code at once. | ||||
GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); | GetMainSignals().RegisterBackgroundSignalScheduler(scheduler); | ||||
mempool.setSanityCheck(1.0); | mempool.setSanityCheck(1.0); | ||||
pblocktree = new CBlockTreeDB(1 << 20, true); | pblocktree.reset(new CBlockTreeDB(1 << 20, true)); | ||||
pcoinsdbview = new CCoinsViewDB(1 << 23, true); | pcoinsdbview.reset(new CCoinsViewDB(1 << 23, true)); | ||||
pcoinsTip = new CCoinsViewCache(pcoinsdbview); | pcoinsTip.reset(new CCoinsViewCache(pcoinsdbview.get())); | ||||
if (!LoadGenesisBlock(chainparams)) { | if (!LoadGenesisBlock(chainparams)) { | ||||
throw std::runtime_error("InitBlockIndex failed."); | throw std::runtime_error("InitBlockIndex failed."); | ||||
} | } | ||||
{ | { | ||||
CValidationState state; | CValidationState state; | ||||
if (!ActivateBestChain(config, state)) { | if (!ActivateBestChain(config, state)) { | ||||
throw std::runtime_error("ActivateBestChain failed."); | throw std::runtime_error("ActivateBestChain failed."); | ||||
} | } | ||||
Show All 12 Lines | |||||
TestingSetup::~TestingSetup() { | TestingSetup::~TestingSetup() { | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
GetMainSignals().FlushBackgroundCallbacks(); | GetMainSignals().FlushBackgroundCallbacks(); | ||||
GetMainSignals().UnregisterBackgroundSignalScheduler(); | GetMainSignals().UnregisterBackgroundSignalScheduler(); | ||||
g_connman.reset(); | g_connman.reset(); | ||||
peerLogic.reset(); | peerLogic.reset(); | ||||
UnloadBlockIndex(); | UnloadBlockIndex(); | ||||
delete pcoinsTip; | pcoinsTip.reset(); | ||||
delete pcoinsdbview; | pcoinsdbview.reset(); | ||||
delete pblocktree; | pblocktree.reset(); | ||||
fs::remove_all(pathTemp); | fs::remove_all(pathTemp); | ||||
} | } | ||||
TestChain100Setup::TestChain100Setup() | TestChain100Setup::TestChain100Setup() | ||||
: TestingSetup(CBaseChainParams::REGTEST) { | : TestingSetup(CBaseChainParams::REGTEST) { | ||||
// Generate a 100-block chain: | // Generate a 100-block chain: | ||||
coinbaseKey.MakeNewKey(true); | coinbaseKey.MakeNewKey(true); | ||||
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) | CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |