[test] Add getblockchaininfo functional test
[bitcoinplatinum.git] / src / qt / test / test_main.cpp
blob4c04e67ccce9687ce69fd1e46c56f09ffab5df71
1 // Copyright (c) 2009-2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #if defined(HAVE_CONFIG_H)
6 #include "config/bitcoin-config.h"
7 #endif
9 #include "chainparams.h"
10 #include "rpcnestedtests.h"
11 #include "util.h"
12 #include "uritests.h"
13 #include "compattests.h"
15 #ifdef ENABLE_WALLET
16 #include "paymentservertests.h"
17 #include "wallettests.h"
18 #endif
20 #include <QApplication>
21 #include <QObject>
22 #include <QTest>
24 #include <openssl/ssl.h>
26 #if defined(QT_STATICPLUGIN)
27 #include <QtPlugin>
28 #if QT_VERSION < 0x050000
29 Q_IMPORT_PLUGIN(qcncodecs)
30 Q_IMPORT_PLUGIN(qjpcodecs)
31 Q_IMPORT_PLUGIN(qtwcodecs)
32 Q_IMPORT_PLUGIN(qkrcodecs)
33 #else
34 #if defined(QT_QPA_PLATFORM_MINIMAL)
35 Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin);
36 #endif
37 #if defined(QT_QPA_PLATFORM_XCB)
38 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
39 #elif defined(QT_QPA_PLATFORM_WINDOWS)
40 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
41 #elif defined(QT_QPA_PLATFORM_COCOA)
42 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
43 #endif
44 #endif
45 #endif
47 extern void noui_connect();
49 // This is all you need to run all the tests
50 int main(int argc, char *argv[])
52 SetupEnvironment();
53 SetupNetworking();
54 SelectParams(CBaseChainParams::MAIN);
55 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());
61 bool fInvalid = false;
63 // Prefer the "minimal" platform for the test instead of the normal default
64 // platform ("xcb", "windows", or "cocoa") so tests can't unintentionally
65 // interfere with any background GUIs and don't require extra resources.
66 #if defined(WIN32)
67 _putenv_s("QT_QPA_PLATFORM", "minimal");
68 #else
69 setenv("QT_QPA_PLATFORM", "minimal", 0);
70 #endif
72 // Don't remove this, it's needed to access
73 // QApplication:: and QCoreApplication:: in the tests
74 QApplication app(argc, argv);
75 app.setApplicationName("Bitcoin-Qt-test");
77 SSL_library_init();
79 URITests test1;
80 if (QTest::qExec(&test1) != 0) {
81 fInvalid = true;
83 #ifdef ENABLE_WALLET
84 PaymentServerTests test2;
85 if (QTest::qExec(&test2) != 0) {
86 fInvalid = true;
88 #endif
89 RPCNestedTests test3;
90 if (QTest::qExec(&test3) != 0) {
91 fInvalid = true;
93 CompatTests test4;
94 if (QTest::qExec(&test4) != 0) {
95 fInvalid = true;
97 #ifdef ENABLE_WALLET
98 WalletTests test5;
99 if (QTest::qExec(&test5) != 0) {
100 fInvalid = true;
102 #endif
104 fs::remove_all(pathTemp);
106 return fInvalid;