10
10
11
11
BOOST_FIXTURE_TEST_SUITE (bech32_tests, BasicTestingSetup)
12
12
13
- BOOST_AUTO_TEST_CASE(bip173_testvectors_valid )
13
+ BOOST_AUTO_TEST_CASE(bech32_testvectors_valid )
14
14
{
15
15
static const std::string CASES[] = {
16
16
" A12UEL5L" ,
@@ -30,7 +30,27 @@ BOOST_AUTO_TEST_CASE(bip173_testvectors_valid)
30
30
}
31
31
}
32
32
33
- BOOST_AUTO_TEST_CASE (bip173_testvectors_invalid)
33
+ BOOST_AUTO_TEST_CASE (bech32m_testvectors_valid)
34
+ {
35
+ static const std::string CASES[] = {
36
+ " A1LQFN3A" ,
37
+ " a1lqfn3a" ,
38
+ " an83characterlonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11sg7hg6" ,
39
+ " abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx" ,
40
+ " 11llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllludsr8" ,
41
+ " split1checkupstagehandshakeupstreamerranterredcaperredlc445v" ,
42
+ " ?1v759aa"
43
+ };
44
+ for (const std::string& str : CASES) {
45
+ const auto dec = bech32::Decode (str);
46
+ BOOST_CHECK (dec.encoding == bech32::Encoding::BECH32M);
47
+ std::string recode = bech32::Encode (bech32::Encoding::BECH32M, dec.hrp , dec.data );
48
+ BOOST_CHECK (!recode.empty ());
49
+ BOOST_CHECK (CaseInsensitiveEqual (str, recode));
50
+ }
51
+ }
52
+
53
+ BOOST_AUTO_TEST_CASE (bech32_testvectors_invalid)
34
54
{
35
55
static const std::string CASES[] = {
36
56
" 1nwldj5" ,
@@ -50,7 +70,31 @@ BOOST_AUTO_TEST_CASE(bip173_testvectors_invalid)
50
70
};
51
71
for (const std::string& str : CASES) {
52
72
const auto dec = bech32::Decode (str);
53
- BOOST_CHECK (dec.encoding != bech32::Encoding::BECH32);
73
+ BOOST_CHECK (dec.encoding == bech32::Encoding::INVALID);
74
+ }
75
+ }
76
+
77
+ BOOST_AUTO_TEST_CASE (bech32m_testvectors_invalid)
78
+ {
79
+ static const std::string CASES[] = {
80
+ " 1xj0phk" ,
81
+ " \x7f " " 1g6xzxy" ,
82
+ " \x80 " " 1vctc34" ,
83
+ " an84characterslonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11d6pts4" ,
84
+ " qyrz8wqd2c9m" ,
85
+ " 1qyrz8wqd2c9m" ,
86
+ " y1b0jsk6g" ,
87
+ " lt1igcx5c0" ,
88
+ " in1muywd" ,
89
+ " mm1crxm3i" ,
90
+ " au1s5cgom" ,
91
+ " M1VUXWEZ" ,
92
+ " 16plkw9" ,
93
+ " 1p2gdwpf"
94
+ };
95
+ for (const std::string& str : CASES) {
96
+ const auto dec = bech32::Decode (str);
97
+ BOOST_CHECK (dec.encoding == bech32::Encoding::INVALID);
54
98
}
55
99
}
56
100
0 commit comments