Skip to content

Commit 984e489

Browse files
ximinezq73zhao
authored andcommitted
test: Add more test cases for Base58 parser (#5174)
--------- Co-authored-by: John Freeman <[email protected]>
1 parent adc30e6 commit 984e489

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

include/xrpl/protocol/detail/b58_utils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ inplace_bigint_div_rem(std::span<uint64_t> numerator, std::uint64_t divisor)
177177
[[nodiscard]] inline std::array<std::uint8_t, 10>
178178
b58_10_to_b58_be(std::uint64_t input)
179179
{
180-
constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10;
180+
[[maybe_unused]] static constexpr std::uint64_t B_58_10 =
181+
430804206899405824; // 58^10;
181182
ASSERT(
182183
input < B_58_10,
183184
"ripple::b58_fast::detail::b58_10_to_b58_be : valid input");

src/test/protocol/types_test.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,16 @@ struct types_test : public beast::unit_test::suite
2828
testAccountID()
2929
{
3030
auto const s = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
31-
if (BEAST_EXPECT(parseBase58<AccountID>(s)))
32-
BEAST_EXPECT(toBase58(*parseBase58<AccountID>(s)) == s);
31+
if (auto const parsed = parseBase58<AccountID>(s); BEAST_EXPECT(parsed))
32+
{
33+
BEAST_EXPECT(toBase58(*parsed) == s);
34+
}
35+
36+
{
37+
auto const s =
38+
"âabcd1rNxp4h8apvRis6mJf9Sh8C6iRxfrDWNâabcdAVâ\xc2\x80\xc2\x8f";
39+
BEAST_EXPECT(!parseBase58<AccountID>(s));
40+
}
3341
}
3442

3543
void

0 commit comments

Comments
 (0)