2014-12-16 22:47:57 -03:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
2014-09-05 07:11:11 -04:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
#include "uritests.h"
|
2013-04-13 02:13:08 -03:00
|
|
|
|
|
|
|
#include "guiutil.h"
|
|
|
|
#include "walletmodel.h"
|
2012-02-10 19:25:36 -03:00
|
|
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
void URITests::uriTests()
|
2012-02-10 19:25:36 -03:00
|
|
|
{
|
|
|
|
SendCoinsRecipient rv;
|
2012-03-25 18:25:10 -03:00
|
|
|
QUrl uri;
|
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(rv.amount == 0);
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example Address"));
|
|
|
|
QVERIFY(rv.amount == 0);
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(rv.amount == 100000);
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
QVERIFY(rv.amount == 100100000);
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
2012-08-07 10:43:58 -04:00
|
|
|
QVERIFY(rv.amount == 10000000000LL);
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.label == QString("Wikipedia Example"));
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
|
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
|
|
|
QVERIFY(rv.label == QString());
|
2012-02-17 11:26:20 -03:00
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
|
2012-02-17 11:26:20 -03:00
|
|
|
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
|
2012-02-10 19:25:36 -03:00
|
|
|
QVERIFY(rv.label == QString());
|
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
|
2013-10-18 08:44:27 -03:00
|
|
|
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
|
2012-03-25 18:25:10 -03:00
|
|
|
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
|
|
|
|
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
|
2012-02-10 19:25:36 -03:00
|
|
|
}
|