Skip to content

Commit

Permalink
Merge #803: test: Set organization name
Browse files Browse the repository at this point in the history
0dcbad3 qt, test: Clean settings after tests (Hennadii Stepanov)
49cf635 qt, test: Set organization name (Hennadii Stepanov)

Pull request description:

  From Qt [docs](https://doc.qt.io/qt-5/qsettings.html#QSettings-4):

  > If [`QCoreApplication::setOrganizationName()`](https://doc.qt.io/qt-5/qcoreapplication.html#organizationName-prop) and [`QCoreApplication::setApplicationName()`](https://doc.qt.io/qt-5/qcoreapplication.html#applicationName-prop) has not been previously called, the `QSettings` object will not be able to read or write any settings, and [`status()`](https://doc.qt.io/qt-5/qsettings.html#status) will return [`AccessError`](https://doc.qt.io/qt-5/qsettings.html#Status-enum).

  Fixes #799.

ACKs for top commit:
  pablomartin4btc:
    utACK 0dcbad3

Tree-SHA512: d5ac160f17cc358f0c1b89097193cd5adfd25f5531955c211f3e0994fc084e0a2b8d3aeddebe38f3a8ab5333edef5aa92b18915885c9e58b33f2e5786f31c600
  • Loading branch information
hebasto committed Mar 7, 2024
2 parents 59567d7 + 0dcbad3 commit c2c6a7d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 19 deletions.
11 changes: 11 additions & 0 deletions src/qt/test/optiontests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ void OptionTests::migrateSettings()

settings.sync();

QVERIFY(settings.contains("nDatabaseCache"));
QVERIFY(settings.contains("nThreadsScriptVerif"));
QVERIFY(settings.contains("fUseUPnP"));
QVERIFY(settings.contains("fListen"));
QVERIFY(settings.contains("bPrune"));
QVERIFY(settings.contains("nPruneSize"));
QVERIFY(settings.contains("fUseProxy"));
QVERIFY(settings.contains("addrProxy"));
QVERIFY(settings.contains("fUseSeparateProxyTor"));
QVERIFY(settings.contains("addrSeparateProxyTor"));

OptionsModel options{m_node};
bilingual_str error;
QVERIFY(options.Init(error));
Expand Down
49 changes: 30 additions & 19 deletions src/qt/test/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <interfaces/init.h>
#include <interfaces/node.h>
#include <qt/bitcoin.h>
#include <qt/guiconstants.h>
#include <qt/test/apptests.h>
#include <qt/test/optiontests.h>
#include <qt/test/rpcnestedtests.h>
Expand All @@ -24,6 +25,7 @@
#include <QApplication>
#include <QDebug>
#include <QObject>
#include <QSettings>
#include <QTest>

#include <functional>
Expand Down Expand Up @@ -83,36 +85,45 @@ int main(int argc, char* argv[])
setenv("QT_QPA_PLATFORM", "minimal", 0 /* overwrite */);
#endif

BitcoinApplication app;
app.setApplicationName("Bitcoin-Qt-test");
app.createNode(*init);

QCoreApplication::setOrganizationName(QAPP_ORG_NAME);
QCoreApplication::setApplicationName(QAPP_APP_NAME_DEFAULT "-test");

int num_test_failures{0};

AppTests app_tests(app);
num_test_failures += QTest::qExec(&app_tests);
{
BitcoinApplication app;
app.createNode(*init);

AppTests app_tests(app);
num_test_failures += QTest::qExec(&app_tests);

OptionTests options_tests(app.node());
num_test_failures += QTest::qExec(&options_tests);
OptionTests options_tests(app.node());
num_test_failures += QTest::qExec(&options_tests);

URITests test1;
num_test_failures += QTest::qExec(&test1);
URITests test1;
num_test_failures += QTest::qExec(&test1);

RPCNestedTests test3(app.node());
num_test_failures += QTest::qExec(&test3);
RPCNestedTests test3(app.node());
num_test_failures += QTest::qExec(&test3);

#ifdef ENABLE_WALLET
WalletTests test5(app.node());
num_test_failures += QTest::qExec(&test5);
WalletTests test5(app.node());
num_test_failures += QTest::qExec(&test5);

AddressBookTests test6(app.node());
num_test_failures += QTest::qExec(&test6);
AddressBookTests test6(app.node());
num_test_failures += QTest::qExec(&test6);
#endif

if (num_test_failures) {
qWarning("\nFailed tests: %d\n", num_test_failures);
} else {
qDebug("\nAll tests passed.\n");
if (num_test_failures) {
qWarning("\nFailed tests: %d\n", num_test_failures);
} else {
qDebug("\nAll tests passed.\n");
}
}

QSettings settings;
settings.clear();

return num_test_failures;
}

0 comments on commit c2c6a7d

Please sign in to comment.