Stop test_bitcoin-qt touching ~/.bitcoin

This commit is contained in:
MeshCollider 2017-08-31 11:15:48 +12:00
parent d81dccf191
commit dea086f498
2 changed files with 6 additions and 7 deletions

View File

@ -37,11 +37,6 @@ void RPCNestedTests::rpcNestedTests()
// do some test setup // do some test setup
// could be moved to a more generic place when we add more tests on QT level // could be moved to a more generic place when we add more tests on QT level
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]); tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
ClearDatadirCache();
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
QDir dir(QString::fromStdString(path));
dir.mkpath(".");
gArgs.ForceSetArg("-datadir", path);
//mempool.setSanityCheck(1.0); //mempool.setSanityCheck(1.0);
TestingSetup test; TestingSetup test;
@ -136,6 +131,4 @@ void RPCNestedTests::rpcNestedTests()
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using , QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using ,
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using , QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
#endif #endif
fs::remove_all(fs::path(path));
} }

View File

@ -53,6 +53,10 @@ int main(int argc, char *argv[])
SetupNetworking(); SetupNetworking();
SelectParams(CBaseChainParams::MAIN); SelectParams(CBaseChainParams::MAIN);
noui_connect(); noui_connect();
ClearDatadirCache();
fs::path pathTemp = fs::temp_directory_path() / strprintf("test_bitcoin-qt_%lu_%i", (unsigned long)GetTime(), (int)GetRand(100000));
fs::create_directories(pathTemp);
gArgs.ForceSetArg("-datadir", pathTemp.string());
bool fInvalid = false; bool fInvalid = false;
@ -97,5 +101,7 @@ int main(int argc, char *argv[])
} }
#endif #endif
fs::remove_all(pathTemp);
return fInvalid; return fInvalid;
} }