-
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
major refactor of ledger_entry
source code and tests
#5237
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #5237 +/- ##
=========================================
+ Coverage 77.9% 78.1% +0.3%
=========================================
Files 791 791
Lines 68006 67658 -348
Branches 8352 8205 -147
=========================================
- Hits 52962 52861 -101
+ Misses 15044 14797 -247
|
6008f56
to
ee2b76f
Compare
@@ -672,7 +672,8 @@ Value::isConvertibleTo(ValueType other) const | |||
(other == intValue && value_.real_ >= minInt && | |||
value_.real_ <= maxInt) || | |||
(other == uintValue && value_.real_ >= 0 && | |||
value_.real_ <= maxUInt) || | |||
value_.real_ <= maxUInt && | |||
static_cast<int>(value_.real_) == value_.real_) || |
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.
You should avoid using == with float point. Consider something like std::fabs(round(value_.real_) - value_.real_) < 1e-10
@@ -385,20 +385,23 @@ ledgerFromRequest(T& ledger, JsonContext& context) | |||
return getLedger(ledger, ledgerHash, context); | |||
} | |||
|
|||
auto const index = indexValue.asString(); | |||
if (indexValue.isConvertibleTo(Json::stringValue)) |
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.
Do we support both forms index: 3
and index: "3"
?
std::uint32_t iVal; | ||
if (beast::lexicalCastChecked(iVal, index)) | ||
return getLedger(ledger, iVal, context); | ||
std::uint32_t iVal; |
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.
Please avoid Hungarian
@@ -36,820 +37,591 @@ | |||
|
|||
namespace ripple { | |||
|
|||
static STArray | |||
parseAuthorizeCredentials(Json::Value const& jv) | |||
static Expected<uint256, Json::Value> |
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.
The moving of the functions makes this change near impossible to review. Consider to make as few differences as possible. Could you please add the new functions to the end of the file and use forward declaration when you need them.
ee2b76f
to
d895d4a
Compare
d895d4a
to
29c7ef9
Compare
29c7ef9
to
72ed5e2
Compare
High Level Overview of Change
This PR is a major refactor of
LedgerEntry.cpp
. It adds a number of helper functions to make the code easier to maintain.It also splits up the
ledger
andledger_entry
tests into different files, and cleans up theledger_entry
tests to make them easier to write and maintain.This refactor also caught a few bugs in some of the other RPC processing, so those are fixed along the way.
Context of Change
The
ledger_entry
code wasn't very readable and was hard to extend whenever a new ledger type was created.Type of Change
API Impact
There are some error code changes. They are made as minimal as possible. The test changes should make it clear what the error code changes are.
Notes for Reviewers
The code has been cleaned up into 3 commits. Reviewing will probably be easier if these commits are reviewed separately, as the overall diff for the tests is very difficult to follow.
ledger
andledger_entry
tests are split up, and theledger_entry
tests are all moved toLedgerEntry_test.cpp
. No actual code changes, just moving code around.Test Plan
Tests pass and have better coverage.