aboutsummaryrefslogtreecommitdiff
path: root/src/qt/test
diff options
context:
space:
mode:
authorKiminuo <kiminuo@protonmail.com>2023-06-21 21:27:00 +0200
committerKiminuo <kiminuo@protonmail.com>2023-06-21 21:34:05 +0200
commitf1d807e383942ae20e080174d33ac17afd649351 (patch)
tree598b29f88793d1021d00bd78c7664e1c1272a6dc /src/qt/test
parentd1ae96755a0f9d7e12c3f6741c030d8ea6d0416f (diff)
Add more tests for the BIP21 implementation
Diffstat (limited to 'src/qt/test')
-rw-r--r--src/qt/test/uritests.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp
index b87d3b21ca..935f078e3d 100644
--- a/src/qt/test/uritests.cpp
+++ b/src/qt/test/uritests.cpp
@@ -58,9 +58,35 @@ void URITests::uriTests()
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
+ // Commas in amounts are not allowed.
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
+
+ // There are two amount specifications. The last value wins.
+ uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&amount=200&label=Wikipedia Example"));
+ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.amount == 20000000000LL);
+ QVERIFY(rv.label == QString("Wikipedia Example"));
+
+ // The first amount value is correct. However, the second amount value is not valid. Hence, the URI is not valid.
+ uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&amount=1,000&label=Wikipedia Example"));
+ QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
+
+ // Test label containing a question mark ('?').
+ uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=?"));
+ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.amount == 10000000000LL);
+ QVERIFY(rv.label == QString("?"));
+
+ // Escape sequences are not supported.
+ uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=%3F"));
+ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
+ QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
+ QVERIFY(rv.amount == 10000000000LL);
+ QVERIFY(rv.label == QString("%3F"));
}