|
|
@ -1,4 +1,4 @@ |
|
|
|
#include "urltests.h" |
|
|
|
#include "uritests.h" |
|
|
|
#include "../guiutil.h" |
|
|
|
#include "../guiutil.h" |
|
|
|
#include "../walletmodel.h" |
|
|
|
#include "../walletmodel.h" |
|
|
|
|
|
|
|
|
|
|
@ -13,59 +13,59 @@ struct SendCoinsRecipient |
|
|
|
}; |
|
|
|
}; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
void URLTests::urlTests() |
|
|
|
void URITests::uriTests() |
|
|
|
{ |
|
|
|
{ |
|
|
|
SendCoinsRecipient rv; |
|
|
|
SendCoinsRecipient rv; |
|
|
|
QUrl url; |
|
|
|
QUrl uri; |
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.amount == 0); |
|
|
|
QVERIFY(rv.amount == 0); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address")); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example Address")); |
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example Address")); |
|
|
|
QVERIFY(rv.amount == 0); |
|
|
|
QVERIFY(rv.amount == 0); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.amount == 100000); |
|
|
|
QVERIFY(rv.amount == 100000); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.amount == 100100000); |
|
|
|
QVERIFY(rv.amount == 100100000); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.amount == 10000000000); |
|
|
|
QVERIFY(rv.amount == 10000000000); |
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example")); |
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example")); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
QVERIFY(rv.label == QString()); |
|
|
|
|
|
|
|
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURL("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv)); |
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv)); |
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); |
|
|
|
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...)
|
|
|
|
// We currently dont implement the message paramenter (ok, yea, we break spec...)
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
|
|
|
|
|
|
|
|
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); |
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); |
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); |
|
|
|
} |
|
|
|
} |