aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-06-26 16:42:33 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-06-27 16:47:23 -0400
commitfaa1e0fb1712b1f94334e42794163f79988270fd (patch)
tree8e7200434658e06054579bffceacb3fda096d1f4 /src
parent7400135b7918df9c34206bead744c496e07b0e78 (diff)
qt: test: Create at most one testing setup
Diffstat (limited to 'src')
-rw-r--r--src/qt/test/apptests.cpp5
-rw-r--r--src/qt/test/paymentservertests.cpp4
-rw-r--r--src/qt/test/rpcnestedtests.cpp3
-rw-r--r--src/qt/test/test_main.cpp12
-rw-r--r--src/test/setup_common.cpp1
5 files changed, 14 insertions, 11 deletions
diff --git a/src/qt/test/apptests.cpp b/src/qt/test/apptests.cpp
index a900ec0198..49e9e072a8 100644
--- a/src/qt/test/apptests.cpp
+++ b/src/qt/test/apptests.cpp
@@ -11,6 +11,8 @@
#include <qt/networkstyle.h>
#include <qt/rpcconsole.h>
#include <shutdown.h>
+#include <test/setup_common.h>
+#include <univalue.h>
#include <validation.h>
#if defined(HAVE_CONFIG_H)
@@ -26,8 +28,6 @@
#include <QtGlobal>
#include <QtTest/QtTestWidgets>
#include <QtTest/QtTestGui>
-#include <string>
-#include <univalue.h>
namespace {
//! Call getblockchaininfo RPC and check first field of JSON output.
@@ -62,6 +62,7 @@ void AppTests::appTests()
}
#endif
+ BasicTestingSetup test{CBaseChainParams::REGTEST}; // Create a temp data directory to backup the gui settings to
ECC_Stop(); // Already started by the common test setup, so stop it to avoid interference
LogInstance().DisconnectTestLogger();
diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp
index f0eca899fc..6cafe05461 100644
--- a/src/qt/test/paymentservertests.cpp
+++ b/src/qt/test/paymentservertests.cpp
@@ -13,7 +13,7 @@
#include <random.h>
#include <script/script.h>
#include <script/standard.h>
-#include <util/system.h>
+#include <test/setup_common.h>
#include <util/strencodings.h>
#include <openssl/x509.h>
@@ -66,7 +66,7 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig
void PaymentServerTests::paymentServerTests()
{
- SelectParams(CBaseChainParams::MAIN);
+ BasicTestingSetup testing_setup(CBaseChainParams::MAIN);
auto node = interfaces::MakeNode();
OptionsModel optionsModel(*node);
PaymentServer* server = new PaymentServer(nullptr, false);
diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp
index 3735f41f9d..3c2ffa6c00 100644
--- a/src/qt/test/rpcnestedtests.cpp
+++ b/src/qt/test/rpcnestedtests.cpp
@@ -34,9 +34,6 @@ void RPCNestedTests::rpcNestedTests()
tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
//mempool.setSanityCheck(1.0);
- ECC_Stop(); // Already started by the common test setup, so stop it to avoid interference
- LogInstance().DisconnectTestLogger();
-
TestingSetup test;
if (RPCIsInWarmup(nullptr)) SetRPCWarmupFinished();
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index 79d88ab742..6bda8dc6eb 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -42,12 +42,18 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
#endif
#endif
-extern void noui_connect();
-
// This is all you need to run all the tests
int main(int argc, char *argv[])
{
- BasicTestingSetup test{CBaseChainParams::REGTEST};
+ // Initialize persistent globals with the testing setup state for sanity.
+ // E.g. -datadir in gArgs is set to a temp directory dummy value (instead
+ // of defaulting to the default datadir), or globalChainParams is set to
+ // regtest params.
+ //
+ // All tests must use their own testing setup (if needed).
+ {
+ BasicTestingSetup dummy{CBaseChainParams::REGTEST};
+ }
auto node = interfaces::MakeNode();
diff --git a/src/test/setup_common.cpp b/src/test/setup_common.cpp
index e3ba9cddb0..24c7d51898 100644
--- a/src/test/setup_common.cpp
+++ b/src/test/setup_common.cpp
@@ -73,7 +73,6 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
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);
// We have to run a scheduler thread to prevent ActivateBestChain