Changeset View
Changeset View
Standalone View
Standalone View
src/qt/test/test_main.cpp
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #endif | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <compat/setenv.h> | #include <compat/setenv.h> | ||||
#include <interfaces/node.h> | #include <interfaces/node.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <util/system.h> | |||||
#include <qt/bitcoin.h> | #include <qt/bitcoin.h> | ||||
#include <qt/test/apptests.h> | #include <qt/test/apptests.h> | ||||
#include <qt/test/bitcoinaddressvalidatortests.h> | #include <qt/test/bitcoinaddressvalidatortests.h> | ||||
#include <qt/test/compattests.h> | #include <qt/test/compattests.h> | ||||
#include <qt/test/guiutiltests.h> | #include <qt/test/guiutiltests.h> | ||||
#include <qt/test/rpcnestedtests.h> | #include <qt/test/rpcnestedtests.h> | ||||
#include <qt/test/uritests.h> | #include <qt/test/uritests.h> | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
#include <qt/test/addressbooktests.h> | #include <qt/test/addressbooktests.h> | ||||
#ifdef ENABLE_BIP70 | #ifdef ENABLE_BIP70 | ||||
#include <qt/test/paymentservertests.h> | #include <qt/test/paymentservertests.h> | ||||
#endif // ENABLE_BIP70 | #endif // ENABLE_BIP70 | ||||
#include <qt/test/wallettests.h> | #include <qt/test/wallettests.h> | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET | ||||
#include <test/setup_common.h> | |||||
#include <QApplication> | #include <QApplication> | ||||
#include <QObject> | #include <QObject> | ||||
#include <QTest> | #include <QTest> | ||||
#ifdef ENABLE_BIP70 | #ifdef ENABLE_BIP70 | ||||
#include <openssl/ssl.h> | #include <openssl/ssl.h> | ||||
#endif | #endif | ||||
Show All 10 Lines | |||||
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); | Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); | ||||
#endif | #endif | ||||
#endif | #endif | ||||
extern void noui_connect(); | extern void noui_connect(); | ||||
// This is all you need to run all the tests | // This is all you need to run all the tests | ||||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||
SetupEnvironment(); | BasicTestingSetup test{CBaseChainParams::REGTEST}; | ||||
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()); | |||||
auto node = interfaces::MakeNode(); | auto node = interfaces::MakeNode(); | ||||
bool fInvalid = false; | bool fInvalid = false; | ||||
// Prefer the "minimal" platform for the test instead of the normal default | // Prefer the "minimal" platform for the test instead of the normal default | ||||
// platform ("xcb", "windows", or "cocoa") so tests can't unintentionally | // platform ("xcb", "windows", or "cocoa") so tests can't unintentionally | ||||
// interfere with any background GUIs and don't require extra resources. | // interfere with any background GUIs and don't require extra resources. | ||||
setenv("QT_QPA_PLATFORM", "minimal", 0); | setenv("QT_QPA_PLATFORM", "minimal", 0); | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | if (QTest::qExec(&test7) != 0) { | ||||
fInvalid = true; | fInvalid = true; | ||||
} | } | ||||
AddressBookTests test8; | AddressBookTests test8; | ||||
if (QTest::qExec(&test8) != 0) { | if (QTest::qExec(&test8) != 0) { | ||||
fInvalid = true; | fInvalid = true; | ||||
} | } | ||||
#endif | #endif | ||||
fs::remove_all(pathTemp); | |||||
return fInvalid; | return fInvalid; | ||||
} | } |