encoding,test: backport BIP350 bech32m and align test vectors to Palladium
- use Bech32 for witness v0 and Bech32m for witness v1+ in key_io - update C++ bech32 tests and python segwit_addr framework - realign key/address test vectors and fixtures to Palladium prefixes/params - adjust chain-parameter-sensitive tests (maturity, BIP66/regtest, message verify) - fix incorrect historical sha256 expected vector in unit tests
This commit is contained in:
@@ -22,9 +22,35 @@ BOOST_AUTO_TEST_CASE(bip173_testvectors_valid)
|
||||
"?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);
|
||||
std::string hrp;
|
||||
std::vector<uint8_t> data;
|
||||
bech32::Encoding encoding = bech32::Decode(str, hrp, data);
|
||||
BOOST_CHECK(encoding == bech32::Encoding::BECH32);
|
||||
BOOST_CHECK(!hrp.empty());
|
||||
std::string recode = bech32::Encode(encoding, hrp, data);
|
||||
BOOST_CHECK(!recode.empty());
|
||||
BOOST_CHECK(CaseInsensitiveEqual(str, recode));
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bip350_testvectors_valid)
|
||||
{
|
||||
static const std::string CASES[] = {
|
||||
"A1LQFN3A",
|
||||
"a1lqfn3a",
|
||||
"an83characterlonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11sg7hg6",
|
||||
"abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx",
|
||||
"11llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllludsr8",
|
||||
"split1checkupstagehandshakeupstreamerranterredcaperredlc445v",
|
||||
"?1v759aa",
|
||||
};
|
||||
for (const std::string& str : CASES) {
|
||||
std::string hrp;
|
||||
std::vector<uint8_t> data;
|
||||
bech32::Encoding encoding = bech32::Decode(str, hrp, data);
|
||||
BOOST_CHECK(encoding == bech32::Encoding::BECH32M);
|
||||
BOOST_CHECK(!hrp.empty());
|
||||
std::string recode = bech32::Encode(encoding, hrp, data);
|
||||
BOOST_CHECK(!recode.empty());
|
||||
BOOST_CHECK(CaseInsensitiveEqual(str, recode));
|
||||
}
|
||||
@@ -47,11 +73,37 @@ BOOST_AUTO_TEST_CASE(bip173_testvectors_invalid)
|
||||
"1qzzfhee",
|
||||
"a12UEL5L",
|
||||
"A12uEL5L",
|
||||
" 1xj0phk",
|
||||
"\x7f""1g6xzxy",
|
||||
"\x80""1vctc34",
|
||||
"an84characterslonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11d6pts4",
|
||||
"qyrz8wqd2c9m",
|
||||
"1qyrz8wqd2c9m",
|
||||
"y1b0jsk6g",
|
||||
"lt1igcx5c0",
|
||||
"in1muywd",
|
||||
"mm1crxm3i",
|
||||
"au1s5cgom",
|
||||
"M1VUXWEZ",
|
||||
"16plkw9",
|
||||
"1p2gdwpf",
|
||||
};
|
||||
for (const std::string& str : CASES) {
|
||||
auto ret = bech32::Decode(str);
|
||||
BOOST_CHECK(ret.first.empty());
|
||||
std::string hrp;
|
||||
std::vector<uint8_t> data;
|
||||
bech32::Encoding encoding = bech32::Decode(str, hrp, data);
|
||||
BOOST_CHECK(encoding == bech32::Encoding::INVALID);
|
||||
BOOST_CHECK(hrp.empty());
|
||||
BOOST_CHECK(data.empty());
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(checksum_type_detection)
|
||||
{
|
||||
std::string hrp;
|
||||
std::vector<uint8_t> data;
|
||||
BOOST_CHECK(bech32::Decode("a12uel5l", hrp, data) == bech32::Encoding::BECH32);
|
||||
BOOST_CHECK(bech32::Decode("a1lqfn3a", hrp, data) == bech32::Encoding::BECH32M);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
Reference in New Issue
Block a user