Add Bitcoin-Qt test suite with some bitcoin: URL Tests to start.
This commit is contained in:
parent
cce89ead18
commit
245484679a
@ -226,6 +226,16 @@ SOURCES += src/qt/qrcodedialog.cpp
|
||||
FORMS += src/qt/forms/qrcodedialog.ui
|
||||
}
|
||||
|
||||
contains(BITCOIN_QT_TEST, 1) {
|
||||
SOURCES += src/qt/test/test_main.cpp \
|
||||
src/qt/test/urltests.cpp
|
||||
HEADERS += src/qt/test/urltests.h
|
||||
DEPENDPATH += src/qt/test
|
||||
QT += testlib
|
||||
TARGET = bitcoin-qt_test
|
||||
DEFINES += BITCOIN_QT_TEST
|
||||
}
|
||||
|
||||
CODECFORTR = UTF-8
|
||||
|
||||
# for lrelease/lupdate
|
||||
|
@ -131,6 +131,7 @@ std::string _(const char* psz)
|
||||
return QCoreApplication::translate("bitcoin-core", psz).toStdString();
|
||||
}
|
||||
|
||||
#ifndef BITCOIN_QT_TEST
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Do this early as we don't want to bother initializing if we are just calling IPC
|
||||
@ -257,3 +258,4 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif // BITCOIN_QT_TEST
|
||||
|
11
src/qt/test/test_main.cpp
Normal file
11
src/qt/test/test_main.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
#include <QTest>
|
||||
#include <QObject>
|
||||
|
||||
#include "urltests.h"
|
||||
|
||||
// This is all you need to run all the tests
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
URLTests test1;
|
||||
QTest::qExec(&test1);
|
||||
}
|
68
src/qt/test/urltests.cpp
Normal file
68
src/qt/test/urltests.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include "urltests.h"
|
||||
#include "../guiutil.h"
|
||||
#include "../walletmodel.h"
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
/*
|
||||
struct SendCoinsRecipient
|
||||
{
|
||||
QString address;
|
||||
QString label;
|
||||
qint64 amount;
|
||||
};
|
||||
*/
|
||||
|
||||
void URLTests::urlTests()
|
||||
{
|
||||
SendCoinsRecipient rv;
|
||||
QUrl url;
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
|
||||
QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
|
||||
QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
||||
QVERIFY(rv.label == QString());
|
||||
QVERIFY(rv.amount == 0);
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
||||
QVERIFY(rv.label == QString("Wikipedia Example Address"));
|
||||
QVERIFY(rv.amount == 0);
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
||||
QVERIFY(rv.label == QString());
|
||||
QVERIFY(rv.amount == 100000);
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
||||
QVERIFY(rv.label == QString());
|
||||
QVERIFY(rv.amount == 100100000);
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
||||
QVERIFY(rv.amount == 10000000000);
|
||||
QVERIFY(rv.label == QString("Wikipedia Example"));
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
|
||||
QVERIFY(GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
||||
QVERIFY(rv.label == QString());
|
||||
QVERIFY(rv.label == QString());
|
||||
|
||||
// We currently dont implement the message paramenter (ok, yea, we break spec...)
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
|
||||
QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
|
||||
QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
|
||||
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
|
||||
QVERIFY(!GUIUtil::parseBitcoinURL(&url, &rv));
|
||||
}
|
15
src/qt/test/urltests.h
Normal file
15
src/qt/test/urltests.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef URLTESTS_H
|
||||
#define URLTESTS_H
|
||||
|
||||
#include <QTest>
|
||||
#include <QObject>
|
||||
|
||||
class URLTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void urlTests();
|
||||
};
|
||||
|
||||
#endif // URLTESTS_H
|
Loading…
Reference in New Issue
Block a user