-
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
Unit tests to recreate invalid index logic error #5242
Conversation
* One hits the global cache, one does not. * Also some extra checking. Co-authored-by: Bronek Kozicki <brok@incorrekt.com>
dda3887
to
95b80a7
Compare
* One hits the global cache, one does not. * Also some extra checking. Co-authored-by: Bronek Kozicki <brok@incorrekt.com>
95b80a7
to
aef823e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #5242 +/- ##
=======================================
Coverage 78.0% 78.0%
=======================================
Files 789 789
Lines 66951 66953 +2
Branches 8111 8106 -5
=======================================
+ Hits 52211 52226 +15
+ Misses 14740 14727 -13
|
src/test/app/Regression_test.cpp
Outdated
auto index = [&](auto account) { | ||
Json::Value req(Json::objectValue); | ||
req[jss::account] = account; | ||
auto const resp = env.rpc("json", "account_info", to_string(req)); | ||
BEAST_EXPECT( | ||
resp.isMember(jss::result) && resp[jss::result].isObject()); | ||
auto const& result = resp[jss::result]; | ||
BEAST_EXPECT( | ||
result.isMember(jss::account_data) && | ||
result[jss::account_data].isObject()); | ||
auto const& ad = result[jss::account_data]; | ||
BEAST_EXPECT(ad.isMember(jss::index) && ad[jss::index].isString()); | ||
uint256 index; | ||
BEAST_EXPECT(index.parseHex(ad[jss::index].asString())); | ||
return index; | ||
}; |
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.
I think this can be greatly simplified by using keylet::account(alice)
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.
excellent idea. That will make this whole lambda unnecessary. I added the necessary proposed changes.
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.
I think this can be greatly simplified by using
keylet::account(alice)
Thanks @mvadari. That was a great observation and suggestion.
src/test/app/Regression_test.cpp
Outdated
auto index = [&](auto account) { | ||
Json::Value req(Json::objectValue); | ||
req[jss::account] = account; | ||
auto const resp = env.rpc("json", "account_info", to_string(req)); | ||
BEAST_EXPECT( | ||
resp.isMember(jss::result) && resp[jss::result].isObject()); | ||
auto const& result = resp[jss::result]; | ||
BEAST_EXPECT( | ||
result.isMember(jss::account_data) && | ||
result[jss::account_data].isObject()); | ||
auto const& ad = result[jss::account_data]; | ||
BEAST_EXPECT(ad.isMember(jss::index) && ad[jss::index].isString()); | ||
uint256 index; | ||
BEAST_EXPECT(index.parseHex(ad[jss::index].asString())); | ||
return index; | ||
}; |
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.
excellent idea. That will make this whole lambda unnecessary. I added the necessary proposed changes.
Co-authored-by: Bronek Kozicki <brok@incorrekt.com>
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.
nice !
Ready to merge once CI finishes. The commit message from the first commit will be sufficient for the merge. |
High Level Overview of Change
Add unit tests and extra checks to reproduce and check that the caching issue fixed in version 2.3.0 is resolved and does not recur.
Context of Change
https://dev.to/ripplexdev/november-25-xrpl-bug-current-status-and-whats-next-b61
The tests were not released with the fix because it makes it obvious how to exploit the issue, which would give bad actors too much information.
Type of Change
Test Plan
Only changes unit tests and an
assert
, so as long as tests pass, all is well.Future Tasks