-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add more test cases for Base58 parser #5174
base: develop
Are you sure you want to change the base?
Conversation
assert(input < B_58_10); | ||
(void)B_58_10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this line do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It fools the compiler into thinking the variable is used, so you don't get unused variable warnings when assert
s are disabled.
In file included from /home/extra/ed/dev/rippled/current/src/ripple/protocol/impl/tokens.cpp:32:
/home/extra/ed/dev/rippled/current/src/ripple/protocol/impl/b58_utils.h: In function ‘std::array<unsigned char, 10> ripple::b58_fast::detail::b58_10_to_b58_be(uint64_t)’:
/home/extra/ed/dev/rippled/current/src/ripple/protocol/impl/b58_utils.h:172:29: warning: unused variable ‘B_58_10’ [-Wunused-variable]
172 | constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10;
| ^~~~~~~
It's just an annoyance, but it was on the branch I had sitting around, so I included it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it would be better to use maybe_unused
attribute:
static constexpr [[maybe_unused]] std::uint64_t B_58_10 = 430804206899405824; // 58^10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I keep forgetting that exists. LOL
The final commit message should not include "NFTs". That function was an unintentional duplicate. Also need to add @thejohnfreeman as a coauthor, since he wrote the original unit test. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5174 +/- ##
=========================================
- Coverage 77.9% 77.9% -0.0%
=========================================
Files 782 782
Lines 66621 66619 -2
Branches 8161 8136 -25
=========================================
- Hits 51902 51899 -3
- Misses 14719 14720 +1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor changes.
assert(input < B_58_10); | ||
(void)B_58_10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case it would be better to use maybe_unused
attribute:
static constexpr [[maybe_unused]] std::uint64_t B_58_10 = 430804206899405824; // 58^10
@@ -30,6 +30,11 @@ struct types_test : public beast::unit_test::suite | |||
auto const s = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"; | |||
if (BEAST_EXPECT(parseBase58<AccountID>(s))) | |||
BEAST_EXPECT(toBase58(*parseBase58<AccountID>(s)) == s); | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] For me the intention is not very clear - is this a deliberate scope introduction or a mistake in using if
statement. To make it clearer I would mark the borders of the scope of if
explicitly to make clearly separate for the new scope.
if (BEAST_EXPECT(parseBase58<AccountID>(s)))
{
BEAST_EXPECT(toBase58(*parseBase58<AccountID>(s)) == s);
}
{
auto const s =
"âabcd1rNxp4h8apvRis6mJf9Sh8C6iRxfrDWNâabcdAVâ\xc2\x80\xc2\x8f";
BEAST_EXPECT(!parseBase58<AccountID>(s));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, now that you mention it, it does look a little off. I changed the test a little bit to make that all clearer, and to remove the need to parse s
twice.
* upstream/develop: Add AMMClawback Transaction (XLS-0073d) (5142) Add hubs.xrpkuwait.com to bootstrap (5169)
* upstream/develop: Fix unity build (5179)
Proposed commit message:
|
Hold merging until after 2.3.0 final release. |
* upstream/develop: Set version to 2.3.0-rc1 Replace Uint192 with Hash192 in server_definitions response (5177) Fix potential deadlock (5124) Introduce Credentials support (XLS-70d): (5103) Fix token comparison in Payment (5172) Add fixAMMv1_2 amendment (5176)
* upstream/develop: fix: include `index` in `server_definitions` RPC (5190) Fix ledger_entry crash on invalid credentials request (5189)
* upstream/develop: Set version to 2.3.0-rc2
High Level Overview of Change
Adds unit tests related to the AccountID handling updated in 2.2.1 (#5078)
Context of Change
2.2.1 was released without all of the relevant unit tests for reasons. This PR finally follows up on that and adds the tests.
(Also fixes an unused variable build warning on Release builds.)
Type of Change