From 47b0543461a1200a93893fa052bab870a09808c5 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Tue, 3 Dec 2024 16:13:31 -0500 Subject: [PATCH] test: Add more test cases for Base58 parser (#5174) --------- Co-authored-by: John Freeman --- include/xrpl/protocol/detail/b58_utils.h | 3 ++- src/test/protocol/types_test.cpp | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index 960b3d8dcb6..76e470f54e7 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -177,7 +177,8 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) [[nodiscard]] inline std::array 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"); diff --git a/src/test/protocol/types_test.cpp b/src/test/protocol/types_test.cpp index ac4314df640..8257d9c6495 100644 --- a/src/test/protocol/types_test.cpp +++ b/src/test/protocol/types_test.cpp @@ -28,8 +28,16 @@ struct types_test : public beast::unit_test::suite testAccountID() { auto const s = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"; - if (BEAST_EXPECT(parseBase58(s))) - BEAST_EXPECT(toBase58(*parseBase58(s)) == s); + if (auto const parsed = parseBase58(s); BEAST_EXPECT(parsed)) + { + BEAST_EXPECT(toBase58(*parsed) == s); + } + + { + auto const s = + "âabcd1rNxp4h8apvRis6mJf9Sh8C6iRxfrDWNâabcdAVâ\xc2\x80\xc2\x8f"; + BEAST_EXPECT(!parseBase58(s)); + } } void