mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-15 06:12:37 -03:00
faec28252c
-BEGIN VERIFY SCRIPT- # Move files for f in $(git ls-files src/test/lib/); do git mv $f src/test/util/; done git mv src/test/setup_common.cpp src/test/util/ git mv src/test/setup_common.h src/test/util/ # Replace Windows paths sed -i -e 's|\\setup_common|\\util\\setup_common|g' $(git grep -l '\\setup_common') sed -i -e 's|src\\test\\lib\\|src\\test\\util\\|g' build_msvc/test_bitcoin/test_bitcoin.vcxproj # Everything else sed -i -e 's|/setup_common|/util/setup_common|g' $(git grep -l 'setup_common') sed -i -e 's|test/lib/|test/util/|g' $(git grep -l 'test/lib/') # Fix include guard sed -i -e 's|BITCOIN_TEST_SETUP_COMMON_H|BITCOIN_TEST_UTIL_SETUP_COMMON_H|g' ./src/test/util/setup_common.h sed -i -e 's|BITCOIN_TEST_LIB_|BITCOIN_TEST_UTIL_|g' $(git grep -l 'BITCOIN_TEST_LIB_') -END VERIFY SCRIPT-
57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
// Copyright (c) 2017 Pieter Wuille
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <bech32.h>
|
|
#include <test/util/setup_common.h>
|
|
#include <test/util/str.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(bech32_tests, BasicTestingSetup)
|
|
|
|
BOOST_AUTO_TEST_CASE(bip173_testvectors_valid)
|
|
{
|
|
static const std::string CASES[] = {
|
|
"A12UEL5L",
|
|
"a12uel5l",
|
|
"an83characterlonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1tt5tgs",
|
|
"abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw",
|
|
"11qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqc8247j",
|
|
"split1checkupstagehandshakeupstreamerranterredcaperred2y9e3w",
|
|
"?1ezyfcl",
|
|
};
|
|
for (const std::string& str : CASES) {
|
|
auto ret = bech32::Decode(str);
|
|
BOOST_CHECK(!ret.first.empty());
|
|
std::string recode = bech32::Encode(ret.first, ret.second);
|
|
BOOST_CHECK(!recode.empty());
|
|
BOOST_CHECK(CaseInsensitiveEqual(str, recode));
|
|
}
|
|
}
|
|
|
|
BOOST_AUTO_TEST_CASE(bip173_testvectors_invalid)
|
|
{
|
|
static const std::string CASES[] = {
|
|
" 1nwldj5",
|
|
"\x7f""1axkwrx",
|
|
"\x80""1eym55h",
|
|
"an84characterslonghumanreadablepartthatcontainsthenumber1andtheexcludedcharactersbio1569pvx",
|
|
"pzry9x0s0muk",
|
|
"1pzry9x0s0muk",
|
|
"x1b4n0q5v",
|
|
"li1dgmt3",
|
|
"de1lg7wt\xff",
|
|
"A1G7SGD8",
|
|
"10a06t8",
|
|
"1qzzfhee",
|
|
"a12UEL5L",
|
|
"A12uEL5L",
|
|
};
|
|
for (const std::string& str : CASES) {
|
|
auto ret = bech32::Decode(str);
|
|
BOOST_CHECK(ret.first.empty());
|
|
}
|
|
}
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|