Changeset View
Changeset View
Standalone View
Standalone View
src/test/cashaddr_tests.cpp
// Copyright (c) 2017 Pieter Wuille | // Copyright (c) 2017 Pieter Wuille | ||||
// Copyright (c) 2017-2019 The Bitcoin developers | // Copyright (c) 2017-2019 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <cashaddr.h> | #include <cashaddr.h> | ||||
#include <test/util/setup_common.h> | #include <test/util/setup_common.h> | ||||
#include <test/util/str.h> | |||||
#include <boost/test/unit_test.hpp> | #include <boost/test/unit_test.hpp> | ||||
static std::pair<std::string, std::vector<uint8_t>> | static std::pair<std::string, std::vector<uint8_t>> | ||||
CashAddrDecode(const std::string &str) { | CashAddrDecode(const std::string &str) { | ||||
return cashaddr::Decode(str, ""); | return cashaddr::Decode(str, ""); | ||||
} | } | ||||
BOOST_FIXTURE_TEST_SUITE(cashaddr_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(cashaddr_tests, BasicTestingSetup) | ||||
bool CaseInsensitiveEqual(const std::string &s1, const std::string &s2) { | |||||
if (s1.size() != s2.size()) { | |||||
return false; | |||||
} | |||||
for (size_t i = 0; i < s1.size(); ++i) { | |||||
char c1 = s1[i]; | |||||
if (c1 >= 'A' && c1 <= 'Z') { | |||||
c1 -= ('A' - 'a'); | |||||
} | |||||
char c2 = s2[i]; | |||||
if (c2 >= 'A' && c2 <= 'Z') { | |||||
c2 -= ('A' - 'a'); | |||||
} | |||||
if (c1 != c2) { | |||||
return false; | |||||
} | |||||
} | |||||
return true; | |||||
} | |||||
BOOST_AUTO_TEST_CASE(cashaddr_testvectors_valid) { | BOOST_AUTO_TEST_CASE(cashaddr_testvectors_valid) { | ||||
static const std::string CASES[] = { | static const std::string CASES[] = { | ||||
"prefix:x64nx6hz", | "prefix:x64nx6hz", | ||||
"PREFIX:X64NX6HZ", | "PREFIX:X64NX6HZ", | ||||
"p:gpf8m4h7", | "p:gpf8m4h7", | ||||
"bitcoincash:qpzry9x8gf2tvdw0s3jn54khce6mua7lcw20ayyn", | "bitcoincash:qpzry9x8gf2tvdw0s3jn54khce6mua7lcw20ayyn", | ||||
"bchtest:testnetaddress4d6njnut", | "bchtest:testnetaddress4d6njnut", | ||||
"bchreg:555555555555555555555555555555555555555555555udxmlmrz", | "bchreg:555555555555555555555555555555555555555555555udxmlmrz", | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |