Skip to content
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

Currently, the ledger command only takes int for ledger_index - update the logic to allow string as well. #3582

Closed
wants to merge 1 commit into from

Conversation

gregtatcam
Copy link
Collaborator

@gregtatcam gregtatcam commented Aug 13, 2020

Assume ledger_index is quoted int if it is not "current", "closed", or "validated".

FIXES #3533

Copy link
Contributor

@cjcobb23 cjcobb23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, @gregtatcam can you write a unit test for this? Then I'll approve

@gregtatcam gregtatcam requested a review from cjcobb23 August 13, 2020 19:25
Copy link
Contributor

@nbougalis nbougalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left some suggestions that I feel improve the code. I'd like to see them adopted unless anyone objects.

src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/ripple/rpc/impl/RPCHelpers.cpp Outdated Show resolved Hide resolved
src/test/rpc/LedgerRPC_test.cpp Show resolved Hide resolved
Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, but I'd like to request a couple of changes.

  1. The DepositAuthorized unit tests are failing as a result of your change. You can choose to fix them yourself, or you could cherry-pick this commit which has a fix: scottschurr@3461cd4

  2. The commit messages need some work. Here is generally good advice to follow: https://chris.beams.io/posts/git-commit/ But there are two specific changes I'd like to see

  • The first line of the first commit message is too long. It should be 60 characters or less. If there's more stuff coming then that first line should end with a colon followed by a blank line followed by the additional stuff. Consider something like this for that first commit message...

RPC ledger_index argument accepts quoted numeric strings:

Some RPC commands return ledger_index as a quoted numeric string.
This change allows the returned value to be directly copied and
used for follow-on RPC commands.

FIXES 3533

  • Presumably the remaining commits will want to be squashed into the first commit when this pull request is merged. Please start the commit message of any commits you want squashed with [FOLD]. The person assembling a release may not have been following the code review. Including [FOLD] helps the person building the release to know whether they have additional work to do. So the second commit message might look like this...

[FOLD] Update unit-test

The additional bug-fix and tuning commits should all include [FOLD] at the front. So, for example, the commit message for the third commit might look like...

[FOLD] Simplify ledger_index parsing:

Change lexicalCastChecked() argument to std::unit32_t.
Update unit-test.

I'm sure you get the idea. Thanks.

@@ -136,7 +136,7 @@ operator!=(StaticString x, std::string const& y)
* The sequence of an #arrayValue will be automatically resize and initialized
* with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
*
* The get() methods can be used to obtanis default value in the case the
* The get() methods can be used to obtain default value in the case the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing and fixing the typo. I think you could slightly improve readability with "...to obtain a default...". But that's at your discretion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. Updated.

@@ -393,7 +419,7 @@ class LedgerRPC_test : public beast::unit_test::suite
void
testLedgerEntryDepositPreauth()
{
testcase("ledger_entry Request Directory");
testcase("ledger_entry Deposit Preauth");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for noticing and fixing this.

@gregtatcam
Copy link
Collaborator Author

Looks pretty good, but I'd like to request a couple of changes.

  1. The DepositAuthorized unit tests are failing as a result of your change. You can choose to fix them yourself, or you could cherry-pick this commit which has a fix: scottschurr@3461cd4
  2. The commit messages need some work. Here is generally good advice to follow: https://chris.beams.io/posts/git-commit/ But there are two specific changes I'd like to see
  • The first line of the first commit message is too long. It should be 60 characters or less. If there's more stuff coming then that first line should end with a colon followed by a blank line followed by the additional stuff. Consider something like this for that first commit message...

RPC ledger_index argument accepts quoted numeric strings:
Some RPC commands return ledger_index as a quoted numeric string.
This change allows the returned value to be directly copied and
used for follow-on RPC commands.
FIXES 3533

  • Presumably the remaining commits will want to be squashed into the first commit when this pull request is merged. Please start the commit message of any commits you want squashed with [FOLD]. The person assembling a release may not have been following the code review. Including [FOLD] helps the person building the release to know whether they have additional work to do. So the second commit message might look like this...

[FOLD] Update unit-test

The additional bug-fix and tuning commits should all include [FOLD] at the front. So, for example, the commit message for the third commit might look like...

[FOLD] Simplify ledger_index parsing:
Change lexicalCastChecked() argument to std::unit32_t.
Update unit-test.

I'm sure you get the idea. Thanks.

Thank you. I fixed the unit test.

I'll update the commit message and squash per your recommendations once the PR is approved.

Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM and continuous integration passes!

Some RPC commands return ledger_index as a quoted numeric string.
This change allows the returned value to be directly copied and
used for follow-on RPC commands.

FIXES 3533

[FOLD] Update unit-test

[FOLD] Simplify ledger index parsing:

Change lexicalCastChecked() argument to std::unit32_t
Update unit-test

[FOLD] Fix unit-test
@carlhua carlhua added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Aug 31, 2020
@nbougalis nbougalis mentioned this pull request Sep 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update ledger command to accept string as ledger_index
5 participants