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

Minor fixes to payment channels commands (RIPD-1466 and RIPD-1467) #2192

Closed
wants to merge 2 commits into from

Conversation

seelabs
Copy link
Collaborator

@seelabs seelabs commented Jul 28, 2017

No description provided.

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.

All I saw was one line with questionable indentation... 👍

@@ -90,15 +90,31 @@ Json::Value doChannelVerify (RPC::Context& context)
{
auto const& params (context.params);
for (auto const& p :
{jss::public_key, jss::channel_id, jss::amount, jss::signature})
{jss::public_key, jss::channel_id, jss::amount, jss::signature})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Micro nit: is the indentation here intentional? Looks like it overshot...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@seelabs
Copy link
Collaborator Author

seelabs commented Aug 1, 2017

Rebased onto 0.80.0-b4

@codecov-io
Copy link

codecov-io commented Aug 1, 2017

Codecov Report

Merging #2192 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2192   +/-   ##
========================================
  Coverage    71.01%   71.01%           
========================================
  Files          691      691           
  Lines        52320    52320           
========================================
  Hits         37153    37153           
  Misses       15167    15167

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc9e9f4...cdcf1e6. Read the comment docs.

pk.emplace(makeSlice(pkHex.first));
}

if (!pk)
Copy link
Contributor

@miguelportilla miguelportilla Aug 11, 2017

Choose a reason for hiding this comment

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

This if can be moved to after the emplace.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not needed. Fixed.


std::pair<Blob, bool> pkHex(strUnHex (strPk));
if (!pkHex.second)
return false;
Copy link
Contributor

@miguelportilla miguelportilla Aug 11, 2017

Choose a reason for hiding this comment

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

Suggestion: This code path doesn't seem to be covered by unit test. We can improve the coverage and test.

return false;

if (!publicKeyType(makeSlice(pkHex.first)))
return false;
Copy link
Contributor

@miguelportilla miguelportilla Aug 11, 2017

Choose a reason for hiding this comment

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

Same here

if (!publicKeyType(makeSlice(pkHex.first)))
return false;

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

{
std::pair<Blob, bool> pkHex(strUnHex (strPk));
if (!pkHex.second)
return rpcError(rpcPUBLIC_MALFORMED);
Copy link
Contributor

@miguelportilla miguelportilla Aug 11, 2017

Choose a reason for hiding this comment

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

Suggestion: This code path doesn't seem to be covered by unit test. We can improve the coverage and test.

return rpcError(rpcPUBLIC_MALFORMED);
auto const pkType = publicKeyType(makeSlice(pkHex.first));
if (!pkType)
return rpcError(rpcPUBLIC_MALFORMED);
Copy link
Contributor

@miguelportilla miguelportilla Aug 11, 2017

Choose a reason for hiding this comment

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

Same here

@seelabs
Copy link
Collaborator Author

seelabs commented Dec 8, 2017

Added a commit to fix an issue with std::stoul and add tests. Also rebased to 0.90.0.

@miguelportilla The places you tagged in an earlier appear to be tested even before this commit. I'm guessing github put the comment on the wrong line of code (I've seen it do this in other commits). I'm assuming you meant to tag the untested code that the new commit now tests.

@ripplelabs-jenkins
Copy link
Collaborator

ripplelabs-jenkins commented Dec 8, 2017

Jenkins Build Summary

Built from this commit

Built at 20171218 - 22:04:44

Test Results

Build Type Result Status
clang.debug.unity 970 cases, 0 failed, t: 387s PASS ✅
coverage 970 cases, 0 failed, t: 602s PASS ✅
clang.debug.nounity 968 cases, 0 failed, t: 294s PASS ✅
gcc.debug.nounity 968 cases, 0 failed, t: 310s PASS ✅
gcc.debug.unity 970 cases, 0 failed, t: 426s PASS ✅
clang.release.unity 969 cases, 0 failed, t: 462s PASS ✅
gcc.release.unity 969 cases, 0 failed, t: 495s PASS ✅

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.

👍 Nice change. Good tests.

You might consider testing with a few other malformed integers besides "x1000", "1000x" and "x". For example, I believe leading spaces are stripped by std::stoul, so " 1000" would not be malformed. But "1,000" should be malformed as should "1000 ". I would expect whitespace and separators to be much more common error cases than miscellaneous xs. Just a thought.

@seelabs
Copy link
Collaborator Author

seelabs commented Dec 12, 2017

@scottschurr Good idea. Pushed tests with leading/trailing/middle spaces and comma

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.

👍 New tests look great, thanks.

So, just to make sure we're on good footing, do we want leading spaces to be okay in this parse? Do the other quoted number parsers allow leading spaces? It's probably not that big a deal if they are not consistent... But it feels like it would be nice if it were consistent. Just a thought.

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.

Changes look good. I just left one thought that may help future maintenance. 👍

namespace ripple {

static
boost::optional<std::uint64_t>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since there are now two identical implementations of this function, how would you feel about putting it in basics/StringUtilities? That way if there are future bugs to fix they will only need to be fixed in one place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered that, but I decided they shouldn't be project-wide utilities. I agree code duplication like this is bad, but too many project-wide utility functions has a cost too. It makes finding the right utility function hard to find because the useful ones are mixed in with ones like this that are only used in two files.

If the two places were in the same subsystem, I'd look for a place in that subsystem to put them. As is, they are in ripple/net and ripple/rpc, so the util would have to live in ripple.

I'm OK promoting this project-wide if you feel strongly, but I still vote for the two (small) duplicated functions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't feel strongly about it. I have a lot of sympathy for the costs associated with too many project-wide utility functions. I regularly thrash about trying to find where some utility function is hidden. I also probably accidentally create duplicate code, since I have no idea that a function already exists that does what I want to do. I'm not sure precisely what to do about either of those problems.

At any rate, my personal take is that this is not an overly specialized function, so I'd be fine with promoting it as a general facility (since it took you a couple of tries to get it to its current state of correctness). But I'm also okay with duplicating it.

Copy link
Contributor

@miguelportilla miguelportilla left a comment

Choose a reason for hiding this comment

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

👍

@seelabs seelabs added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Dec 18, 2017
@seelabs
Copy link
Collaborator Author

seelabs commented Dec 18, 2017

Squashed and rebased onto 0.90.0-b2

@nbougalis nbougalis mentioned this pull request Jan 10, 2018
@seelabs
Copy link
Collaborator Author

seelabs commented Jan 16, 2018

In 0.90.0-b3

@seelabs seelabs closed this Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants