2021-12-30 19:36:57 +02:00
|
|
|
// Copyright (c) 2009-2021 The Bitcoin Core developers
|
2014-09-05 13:11:11 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
2017-11-10 13:57:53 +13:00
|
|
|
#include <config/bitcoin-config.h>
|
2013-12-11 15:00:56 +01:00
|
|
|
#endif
|
|
|
|
|
2017-12-05 15:57:12 -05:00
|
|
|
#include <interfaces/init.h>
|
2017-11-06 20:11:43 -05:00
|
|
|
#include <interfaces/node.h>
|
|
|
|
#include <qt/bitcoin.h>
|
|
|
|
#include <qt/test/apptests.h>
|
2017-11-10 13:57:53 +13:00
|
|
|
#include <qt/test/rpcnestedtests.h>
|
|
|
|
#include <qt/test/uritests.h>
|
2019-11-05 15:18:59 -05:00
|
|
|
#include <test/util/setup_common.h>
|
2014-09-05 13:11:11 +02:00
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2018-03-29 10:59:57 -04:00
|
|
|
#include <qt/test/addressbooktests.h>
|
2017-11-10 13:57:53 +13:00
|
|
|
#include <qt/test/wallettests.h>
|
2017-11-06 19:12:47 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2013-04-13 00:13:08 -05:00
|
|
|
|
2017-03-10 15:58:53 -05:00
|
|
|
#include <QApplication>
|
2013-04-13 00:13:08 -05:00
|
|
|
#include <QObject>
|
|
|
|
#include <QTest>
|
2013-07-22 16:50:39 +10:00
|
|
|
|
2017-03-14 20:45:00 -04:00
|
|
|
#if defined(QT_STATICPLUGIN)
|
2013-12-18 15:46:48 -05:00
|
|
|
#include <QtPlugin>
|
2017-04-03 11:07:40 -04:00
|
|
|
#if defined(QT_QPA_PLATFORM_MINIMAL)
|
|
|
|
Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin);
|
|
|
|
#endif
|
2017-03-14 20:45:00 -04:00
|
|
|
#if defined(QT_QPA_PLATFORM_XCB)
|
|
|
|
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
|
|
|
|
#elif defined(QT_QPA_PLATFORM_WINDOWS)
|
|
|
|
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
|
|
|
|
#elif defined(QT_QPA_PLATFORM_COCOA)
|
|
|
|
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
|
2021-12-12 08:15:06 +01:00
|
|
|
#elif defined(QT_QPA_PLATFORM_ANDROID)
|
|
|
|
Q_IMPORT_PLUGIN(QAndroidPlatformIntegrationPlugin)
|
2017-03-14 20:45:00 -04:00
|
|
|
#endif
|
|
|
|
#endif
|
2013-12-18 15:46:48 -05:00
|
|
|
|
2021-11-12 10:06:00 -05:00
|
|
|
using node::NodeContext;
|
|
|
|
|
2019-09-27 11:53:34 -04:00
|
|
|
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
|
|
|
|
2013-07-22 16:50:39 +10:00
|
|
|
// This is all you need to run all the tests
|
2020-05-11 17:40:21 +02:00
|
|
|
int main(int argc, char* argv[])
|
2013-07-22 16:50:39 +10:00
|
|
|
{
|
2019-06-26 16:42:33 -04:00
|
|
|
// 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};
|
|
|
|
}
|
2019-05-28 14:34:50 -04:00
|
|
|
|
2017-12-05 15:57:12 -05:00
|
|
|
std::unique_ptr<interfaces::Init> init = interfaces::MakeGuiInit(argc, argv);
|
2021-03-01 16:10:46 -05:00
|
|
|
gArgs.ForceSetArg("-listen", "0");
|
|
|
|
gArgs.ForceSetArg("-listenonion", "0");
|
|
|
|
gArgs.ForceSetArg("-discover", "0");
|
|
|
|
gArgs.ForceSetArg("-dnsseed", "0");
|
|
|
|
gArgs.ForceSetArg("-fixedseeds", "0");
|
|
|
|
gArgs.ForceSetArg("-upnp", "0");
|
|
|
|
gArgs.ForceSetArg("-natpmp", "0");
|
2016-08-20 11:19:35 +02:00
|
|
|
|
2013-07-22 16:50:39 +10:00
|
|
|
bool fInvalid = false;
|
|
|
|
|
2017-04-03 11:07:40 -04:00
|
|
|
// Prefer the "minimal" platform for the test instead of the normal default
|
2017-08-16 00:24:39 +02:00
|
|
|
// platform ("xcb", "windows", or "cocoa") so tests can't unintentionally
|
2017-04-03 11:07:40 -04:00
|
|
|
// interfere with any background GUIs and don't require extra resources.
|
2017-07-21 17:20:14 -04:00
|
|
|
#if defined(WIN32)
|
2019-10-01 17:03:09 -04:00
|
|
|
if (getenv("QT_QPA_PLATFORM") == nullptr) _putenv_s("QT_QPA_PLATFORM", "minimal");
|
2017-07-21 17:20:14 -04:00
|
|
|
#else
|
2021-09-15 11:10:51 +02:00
|
|
|
setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */);
|
2017-07-21 17:20:14 -04:00
|
|
|
#endif
|
2017-04-03 11:07:40 -04:00
|
|
|
|
2013-11-14 19:21:16 +01:00
|
|
|
// Don't remove this, it's needed to access
|
2017-03-10 15:58:53 -05:00
|
|
|
// QApplication:: and QCoreApplication:: in the tests
|
2018-08-23 13:42:31 -04:00
|
|
|
BitcoinApplication app;
|
2013-11-14 19:21:16 +01:00
|
|
|
app.setApplicationName("Bitcoin-Qt-test");
|
2017-12-05 15:57:12 -05:00
|
|
|
app.createNode(*init);
|
2013-11-14 19:21:16 +01:00
|
|
|
|
2017-11-06 20:11:43 -05:00
|
|
|
AppTests app_tests(app);
|
|
|
|
if (QTest::qExec(&app_tests) != 0) {
|
|
|
|
fInvalid = true;
|
|
|
|
}
|
2013-07-22 16:50:39 +10:00
|
|
|
URITests test1;
|
2017-03-15 13:02:02 -04:00
|
|
|
if (QTest::qExec(&test1) != 0) {
|
2013-07-22 16:50:39 +10:00
|
|
|
fInvalid = true;
|
2017-03-15 13:02:02 -04:00
|
|
|
}
|
2018-08-23 13:42:31 -04:00
|
|
|
RPCNestedTests test3(app.node());
|
2017-03-15 13:02:02 -04:00
|
|
|
if (QTest::qExec(&test3) != 0) {
|
2016-08-20 11:19:35 +02:00
|
|
|
fInvalid = true;
|
2017-03-15 13:02:02 -04:00
|
|
|
}
|
2017-03-10 15:58:53 -05:00
|
|
|
#ifdef ENABLE_WALLET
|
2018-08-23 13:42:31 -04:00
|
|
|
WalletTests test5(app.node());
|
2017-03-10 15:58:53 -05:00
|
|
|
if (QTest::qExec(&test5) != 0) {
|
|
|
|
fInvalid = true;
|
|
|
|
}
|
2018-08-23 13:42:31 -04:00
|
|
|
AddressBookTests test6(app.node());
|
2018-03-29 10:59:57 -04:00
|
|
|
if (QTest::qExec(&test6) != 0) {
|
|
|
|
fInvalid = true;
|
|
|
|
}
|
2017-03-10 15:58:53 -05:00
|
|
|
#endif
|
2013-07-22 16:50:39 +10:00
|
|
|
|
|
|
|
return fInvalid;
|
|
|
|
}
|