-
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
Minor fixes to payment channels commands (RIPD-1466 and RIPD-1467) #2192
Conversation
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.
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}) |
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.
Micro nit: is the indentation here intentional? Looks like it overshot...
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.
Fixed
Rebased onto 0.80.0-b4 |
Codecov Report
@@ 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.
|
pk.emplace(makeSlice(pkHex.first)); | ||
} | ||
|
||
if (!pk) |
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.
This if
can be moved to after the emplace.
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's not needed. Fixed.
|
||
std::pair<Blob, bool> pkHex(strUnHex (strPk)); | ||
if (!pkHex.second) | ||
return false; |
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.
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; |
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.
Same here
if (!publicKeyType(makeSlice(pkHex.first))) | ||
return false; | ||
|
||
return true; |
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.
Same here
{ | ||
std::pair<Blob, bool> pkHex(strUnHex (strPk)); | ||
if (!pkHex.second) | ||
return rpcError(rpcPUBLIC_MALFORMED); |
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.
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); |
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.
Same here
Added a commit to fix an issue with @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. |
Jenkins Build SummaryBuilt from this commit Built at 20171218 - 22:04:44 Test Results
|
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 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 x
s. Just a thought.
@scottschurr Good idea. Pushed tests with leading/trailing/middle spaces and comma |
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.
👍 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.
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.
Changes look good. I just left one thought that may help future maintenance. 👍
namespace ripple { | ||
|
||
static | ||
boost::optional<std::uint64_t> |
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.
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.
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 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.
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 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.
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.
👍
04d014d
to
cdcf1e6
Compare
Squashed and rebased onto 0.90.0-b2 |
In 0.90.0-b3 |
No description provided.