aboutsummaryrefslogtreecommitdiff
path: root/src/qt/test/urltests.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2012-02-12 05:52:34 -0800
committerWladimir J. van der Laan <laanwj@gmail.com>2012-02-12 05:52:34 -0800
commit15b87b2ec40bdcbc7e8173c79b829fc0f550909e (patch)
treec8e5a9f35d20d22a76b9c67dee073c0fb38bd706 /src/qt/test/urltests.cpp
parentd27b4576f35002a2da8703aec0f3b97208fd0dcd (diff)
parent245484679adbde8df6b0b01baa24393ea20a7aed (diff)
Merge pull request #807 from TheBlueMatt/bip21
Add req- prefixes to comply with BIP21.
Diffstat (limited to 'src/qt/test/urltests.cpp')
-rw-r--r--src/qt/test/urltests.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/qt/test/urltests.cpp b/src/qt/test/urltests.cpp
new file mode 100644
index 0000000000..5ecc846203
--- /dev/null
+++ b/src/qt/test/urltests.cpp
@@ -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));
+}