Changeset View
Changeset View
Standalone View
Standalone View
src/test/test_bitcoin.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
BasicTestingSetup::~BasicTestingSetup() { | BasicTestingSetup::~BasicTestingSetup() { | ||||
ECC_Stop(); | ECC_Stop(); | ||||
} | } | ||||
TestingSetup::TestingSetup(const std::string &chainName) | TestingSetup::TestingSetup(const std::string &chainName) | ||||
: BasicTestingSetup(chainName) { | : BasicTestingSetup(chainName) { | ||||
const Config &config = GetConfig(); | |||||
const CChainParams &chainparams = config.GetChainParams(); | |||||
// Ideally we'd move all the RPC tests to the functional testing framework | // Ideally we'd move all the RPC tests to the functional testing framework | ||||
// instead of unit tests, but for now we need these here. | // instead of unit tests, but for now we need these here. | ||||
const Config &config = GetConfig(); | |||||
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, | // 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 = 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 (!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 20 Lines • Show All 157 Lines • Show Last 20 Lines |