Skip to content

Commit

Permalink
gui: use common setup in gui tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed May 28, 2019
1 parent faa2a47 commit fa6bb8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/qt/test/apptests.cpp
Expand Up @@ -6,6 +6,7 @@

#include <chainparams.h>
#include <init.h>
#include <key.h>
#include <qt/bitcoin.h>
#include <qt/bitcoingui.h>
#include <qt/networkstyle.h>
Expand Down Expand Up @@ -66,6 +67,7 @@ void AppTests::appTests()
}
#endif

ECC_Stop(); // Already started by the common test setup, so stop it to avoid interference
m_app.parameterSetup();
m_app.createOptionsModel(true /* reset settings */);
QScopedPointer<const NetworkStyle> style(
Expand Down
18 changes: 6 additions & 12 deletions src/qt/test/test_main.cpp
Expand Up @@ -10,10 +10,11 @@
#include <interfaces/node.h>
#include <qt/bitcoin.h>
#include <qt/test/apptests.h>
#include <qt/test/compattests.h>
#include <qt/test/rpcnestedtests.h>
#include <util/system.h>
#include <qt/test/uritests.h>
#include <qt/test/compattests.h>
#include <test/setup_common.h>
#include <util/system.h>

#ifdef ENABLE_WALLET
#include <qt/test/addressbooktests.h>
Expand Down Expand Up @@ -48,14 +49,9 @@ extern void noui_connect();
// This is all you need to run all the tests
int main(int argc, char *argv[])
{
SetupEnvironment();
SetupNetworking();
SelectParams(CBaseChainParams::REGTEST);
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());
BasicTestingSetup test{CBaseChainParams::REGTEST};
test.SetDataDir("gui");

auto node = interfaces::MakeNode();

bool fInvalid = false;
Expand Down Expand Up @@ -109,7 +105,5 @@ int main(int argc, char *argv[])
}
#endif

fs::remove_all(pathTemp);

return fInvalid;
}
2 changes: 1 addition & 1 deletion src/test/setup_common.cpp
Expand Up @@ -61,6 +61,7 @@ fs::path BasicTestingSetup::SetDataDir(const std::string& name)
fs::path ret = m_path_root / name;
fs::create_directories(ret);
gArgs.ForceSetArg("-datadir", ret.string());
ClearDatadirCache();
return ret;
}

Expand All @@ -72,7 +73,6 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
// 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.
Expand Down

0 comments on commit fa6bb8a

Please sign in to comment.