test: Create data dir in BasicTestingSetup

This commit is contained in:
MarcoFalke
2019-06-19 17:52:35 -04:00
parent b1344eac5f
commit fad3d2a624
11 changed files with 28 additions and 42 deletions

View File

@@ -34,6 +34,9 @@ std::ostream& operator<<(std::ostream& os, const uint256& num)
BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
: m_path_root(fs::temp_directory_path() / "test_common_" PACKAGE_NAME / strprintf("%lu_%i", (unsigned long)GetTime(), (int)(InsecureRandRange(1 << 30))))
{
fs::create_directories(m_path_root);
gArgs.ForceSetArg("-datadir", m_path_root.string());
ClearDatadirCache();
SHA256AutoDetect();
ECC_Start();
SetupEnvironment();
@@ -55,23 +58,13 @@ BasicTestingSetup::~BasicTestingSetup()
ECC_Stop();
}
fs::path BasicTestingSetup::SetDataDir(const std::string& name)
{
fs::path ret = m_path_root / name;
fs::create_directories(ret);
gArgs.ForceSetArg("-datadir", ret.string());
return ret;
}
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
{
SetDataDir("tempdir");
const CChainParams& chainparams = Params();
// Ideally we'd move all the RPC tests to the functional testing framework
// instead of unit tests, but for now we need these here.
RegisterAllCoreRPCCommands(tableRPC);
ClearDatadirCache();
// We have to run a scheduler thread to prevent ActivateBestChain
// from blocking due to queue overrun.