2012-03-25 23:25:10 +02:00
|
|
|
#include "uritests.h"
|
2012-02-10 23:25:36 +01:00
|
|
|
#include "../guiutil.h"
|
|
|
|
#include "../walletmodel.h"
|
|
|
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
/*
|
|
|
|
struct SendCoinsRecipient
|
|
|
|
{
|
|
|
|
QString address;
|
|
|
|
QString label;
|
|
|
|
qint64 amount;
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
void URITests::uriTests()
|
2012-02-10 23:25:36 +01:00
|
|
|
{
|
|
|
|
SendCoinsRecipient rv;
|
2012-03-25 23:25:10 +02:00
|
|
|
QUrl uri;
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(rv.amount == 0);
|
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example Address"));
|
|
|
|
QVERIFY(rv.amount == 0);
|
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(rv.amount == 100000);
|
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(rv.amount == 100100000);
|
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.amount == 10000000000);
|
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example"));
|
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
2012-02-17 15:26:20 +01:00
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
|
2012-02-17 15:26:20 +01:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
2012-02-10 23:25:36 +01:00
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
|
|
|
|
// We currently dont implement the message paramenter (ok, yea, we break spec...)
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
|
2012-03-25 23:25:10 +02:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 23:25:36 +01:00
|
|
|
}
|