Skip to content

Commit dea086f

Browse files
committed
Stop test_bitcoin-qt touching ~/.bitcoin
1 parent d81dccf commit dea086f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/qt/test/rpcnestedtests.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ void RPCNestedTests::rpcNestedTests()
3737
// do some test setup
3838
// could be moved to a more generic place when we add more tests on QT level
3939
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
40-
ClearDatadirCache();
41-
std::string path = QDir::tempPath().toStdString() + "/" + strprintf("test_bitcoin_qt_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
42-
QDir dir(QString::fromStdString(path));
43-
dir.mkpath(".");
44-
gArgs.ForceSetArg("-datadir", path);
4540
//mempool.setSanityCheck(1.0);
4641

4742
TestingSetup test;
@@ -136,6 +131,4 @@ void RPCNestedTests::rpcNestedTests()
136131
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using ,
137132
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
138133
#endif
139-
140-
fs::remove_all(fs::path(path));
141134
}

src/qt/test/test_main.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ int main(int argc, char *argv[])
5353
SetupNetworking();
5454
SelectParams(CBaseChainParams::MAIN);
5555
noui_connect();
56+
ClearDatadirCache();
57+
fs::path pathTemp = fs::temp_directory_path() / strprintf("test_bitcoin-qt_%lu_%i", (unsigned long)GetTime(), (int)GetRand(100000));
58+
fs::create_directories(pathTemp);
59+
gArgs.ForceSetArg("-datadir", pathTemp.string());
5660

5761
bool fInvalid = false;
5862

@@ -97,5 +101,7 @@ int main(int argc, char *argv[])
97101
}
98102
#endif
99103

104+
fs::remove_all(pathTemp);
105+
100106
return fInvalid;
101107
}

0 commit comments

Comments
 (0)