Skip to content

Commit

Permalink
test: Add more test cases for Base58 parser (XRPLF#5174)
Browse files Browse the repository at this point in the history
---------
Co-authored-by: John Freeman <[email protected]>
  • Loading branch information
ximinez authored Dec 3, 2024
1 parent 8215c60 commit 47b0543
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/xrpl/protocol/detail/b58_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ inplace_bigint_div_rem(std::span<uint64_t> numerator, std::uint64_t divisor)
[[nodiscard]] inline std::array<std::uint8_t, 10>
b58_10_to_b58_be(std::uint64_t input)
{
constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10;
[[maybe_unused]] static constexpr std::uint64_t B_58_10 =
430804206899405824; // 58^10;
ASSERT(
input < B_58_10,
"ripple::b58_fast::detail::b58_10_to_b58_be : valid input");
Expand Down
12 changes: 10 additions & 2 deletions src/test/protocol/types_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@ struct types_test : public beast::unit_test::suite
testAccountID()
{
auto const s = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
if (BEAST_EXPECT(parseBase58<AccountID>(s)))
BEAST_EXPECT(toBase58(*parseBase58<AccountID>(s)) == s);
if (auto const parsed = parseBase58<AccountID>(s); BEAST_EXPECT(parsed))
{
BEAST_EXPECT(toBase58(*parsed) == s);
}

{
auto const s =
"âabcd1rNxp4h8apvRis6mJf9Sh8C6iRxfrDWNâabcdAVâ\xc2\x80\xc2\x8f";
BEAST_EXPECT(!parseBase58<AccountID>(s));
}
}

void
Expand Down

0 comments on commit 47b0543

Please sign in to comment.