Changeset View
Changeset View
Standalone View
Standalone View
src/qt/test/uritests.cpp
Show First 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | uri.setUrl(QString( | ||||
"bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a?amount=1," | "bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a?amount=1," | ||||
"000.0&label=Wikipedia Example")); | "000.0&label=Wikipedia Example")); | ||||
QVERIFY(!GUIUtil::parseBitcoinURI(scheme, uri, &rv)); | QVERIFY(!GUIUtil::parseBitcoinURI(scheme, uri, &rv)); | ||||
} | } | ||||
namespace { | namespace { | ||||
class UriTestConfig : public DummyConfig { | class UriTestConfig : public DummyConfig { | ||||
public: | public: | ||||
UriTestConfig(bool useCashAddr) : useCashAddr(useCashAddr) {} | UriTestConfig(bool useCashAddr) | ||||
: useCashAddr(useCashAddr), net(CBaseChainParams::MAIN) {} | |||||
bool UseCashAddrEncoding() const override { return useCashAddr; } | bool UseCashAddrEncoding() const override { return useCashAddr; } | ||||
const CChainParams &GetChainParams() const override { return Params(net); } | |||||
void SetChainParams(const std::string &n) { net = n; } | |||||
private: | private: | ||||
bool useCashAddr; | bool useCashAddr; | ||||
std::string net; | |||||
}; | }; | ||||
} // anon ns | } // anon ns | ||||
void URITests::uriTestFormatURI() { | void URITests::uriTestFormatURI() { | ||||
{ | { | ||||
UriTestConfig cfg(true); | UriTestConfig cfg(true); | ||||
SendCoinsRecipient r; | SendCoinsRecipient r; | ||||
Show All 9 Lines | void URITests::uriTestFormatURI() { | ||||
SendCoinsRecipient r; | SendCoinsRecipient r; | ||||
r.address = "175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"; | r.address = "175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"; | ||||
r.message = "test"; | r.message = "test"; | ||||
QString uri = GUIUtil::formatBitcoinURI(cfg, r); | QString uri = GUIUtil::formatBitcoinURI(cfg, r); | ||||
QVERIFY(uri == | QVERIFY(uri == | ||||
"bitcoincash:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=test"); | "bitcoincash:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=test"); | ||||
} | } | ||||
} | } | ||||
void URITests::uriTestScheme() { | |||||
{ | |||||
// cashaddr - scheme depends on selected chain params | |||||
UriTestConfig config(true); | |||||
config.SetChainParams(CBaseChainParams::MAIN); | |||||
QVERIFY("bitcoincash" == GUIUtil::bitcoinURIScheme(config)); | |||||
config.SetChainParams(CBaseChainParams::TESTNET); | |||||
QVERIFY("bchtest" == GUIUtil::bitcoinURIScheme(config)); | |||||
config.SetChainParams(CBaseChainParams::REGTEST); | |||||
QVERIFY("bchreg" == GUIUtil::bitcoinURIScheme(config)); | |||||
} | |||||
{ | |||||
// legacy - scheme is "bitcoincash" regardless of chain params | |||||
UriTestConfig config(false); | |||||
config.SetChainParams(CBaseChainParams::MAIN); | |||||
QVERIFY("bitcoincash" == GUIUtil::bitcoinURIScheme(config)); | |||||
config.SetChainParams(CBaseChainParams::TESTNET); | |||||
QVERIFY("bitcoincash" == GUIUtil::bitcoinURIScheme(config)); | |||||
config.SetChainParams(CBaseChainParams::REGTEST); | |||||
QVERIFY("bitcoincash" == GUIUtil::bitcoinURIScheme(config)); | |||||
} | |||||
} |