-
Notifications
You must be signed in to change notification settings - Fork 29
Move rippled dependencies into ripple-libpp #16
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #16 +/- ##
===========================================
- Coverage 100% 83.16% -16.84%
===========================================
Files 1 76 +75
Lines 143 3997 +3854
===========================================
+ Hits 143 3324 +3181
- Misses 0 673 +673
Continue to review full report at Codecov.
|
dcd7dfe to
e78c1eb
Compare
fd673f0 to
65abd05
Compare
|
@ximinez @scottschurr I think this is ready for full review. Mind taking a look? |
|
Will do as soon as I can. |
|
Travis build failed. Expected? |
|
CI builds should not fail. It looks like the |
715bcc0 to
d795e35
Compare
|
Rebased with working Travis CI builds. |
| bool (vm.count ("quiet")), | ||
| bool (vm.count ("unittest-log"))); | ||
| } | ||
| } |
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.
Clang suggests that an integer should be returned here. Zero?
|
There are a lot of changes here, clearly more than I could realistically review to any depth. Do you have some guidance for where I should spend my review time? What was the basic process you followed to make these changes? Thanks. |
|
@scottschurr basically avoid any of the dependencies in the src/ folder. Here are some of the main files:
|
scottschurr
left a comment
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.
Generally things look pretty good. It seems like you're getting better about tagging things const when you can. Keep that up! Still, I pointed out a few things you might want to tend to.
In terms of testing, I believe the only consumer of this library right now is ripple-sign-serialize. You may have already tried this, but is there a way to test that with these modifications ripple-sign-serialize still links and runs? It would be comforting to see that work.
| @@ -0,0 +1,154 @@ | |||
| //------------------------------------------------------------------------------ | |||
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 did a search and it looks like all of the other test-like files are named *_test.cpp. There may be a good reason for this file to violate that pattern, but if there isn't I'd suggest naming this file ripple-libpp_test.cpp. Consistency may be the hobgoblin of little minds, but it makes programming easier 😸
| #include <boost/filesystem.hpp> | ||
| #include <boost/format.hpp> | ||
| #include <boost/program_options.hpp> | ||
| #include <test/quiet_reporter.h> |
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.
For me, using clang on mac OS, quite a few of these #includes are not needed. Here's what was left after I removed the un-needed includes:
#include <BeastConfig.h>
// #include <ripple/beast/core/SemanticVersion.h>
// #include <ripple/basics/CheckLibraryVersions.h>
#include <ripple/beast/unit_test.h>
// #include <ripple/core/Config.h>
// #include <ripple/core/ConfigSections.h>
// #include <ripple/core/TerminateHandler.h>
// #include <ripple/protocol/SystemParameters.h>
#include <ripple/protocol/BuildInfo.h>
#include <beast/unit_test/dstream.hpp>
// #include <boost/algorithm/string/trim.hpp>
// #include <boost/filesystem.hpp>
// #include <boost/format.hpp>
#include <boost/program_options.hpp>
#include <test/quiet_reporter.h>
| po::variables_map vm; | ||
|
|
||
| // Set up option parsing. | ||
| po::options_description desc ("General Options"); |
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.
For your amusement, try running the following command:
./ripplelibpptest --help
The response I'm getting is:
rippled: Incorrect command line syntax.
Use '--help' for a list of options.
😸
| // Set up option parsing. | ||
| po::options_description desc ("General Options"); | ||
| desc.add_options () | ||
| ("unittest,u", po::value <std::string> ()->implicit_value (""), "Perform unit tests.") |
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.
They can also run a subset of the unit tests. For example try:
./ripplelibpptest --unittest=STAmount
That capability might be nice to document.
src/test/ripple-libpp_unittest.cpp
Outdated
| argument = vm["unittest-arg"].as<std::string>(); | ||
| return runUnitTests( | ||
| vm["unittest"].as<std::string>(), argument, | ||
| bool (vm.count ("quiet")), |
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 spotted four casts to bool in this file. They are all okay, but I'll express my preference. There are two options:
-
You could remove the four casts entirely. C++ has legacy rules from C. Parameters in a function call go through implicit conversions. One of these conversions is from integer to boolean. So if you remove the casts then the compiler will automatically convert a non-zero count to
trueand a zero count tofalse. -
If you like to be explicit about conversions, my personal preference is to use C++style casts, rather than C-style or function-style casts. So if you choose to retain the casts, I would prefer they look like:
static_cast<bool>(vm.count ("quiet"))
One of the reasons for that preference is that a C-style or function-style cast can silently become a reinterpret_cast during maintenance. See C++ Coding Standards by Sutter and Alexandresu, item 95 for a full justification.
| @@ -0,0 +1,165 @@ | |||
| //------------------------------------------------------------------------------ | |||
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.
Unfortunately fixing the BeastConfig.h file is outside the scope of this project.
- It has the wrong name.
- I'm pretty sure that most of the #defines it contains are obsolete/unneeded.
- It would be great to get rid of it altogether. It gives all of our *.cpp files a certain fragility.
But I'm guessing you did the right thing by just hauling it along in its current form...
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.
Maybe I could bring it up in #cpp-informal? Would be good to remove 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.
Agreed, it would be good to remove. I'm unsure who you're getting your marching orders from, or how much longer your internship lasts. If you have time and permission, then I think either removing or reducing and renaming BeastConfig.h would be a nice step forward. But it would want to be in a separate pull request.
|
@scottschurr https://github.com/ripple/validator-keys-tool also uses the lib. |
Resolves: RIPD-1469 Adds tests for protocol, beast, and basics with accompanying test binary. Includes accompaying dependencies and test directories from rippled.
|
Squashed and updated commit message. |
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.
Sorry for leaving this to sit for so long.
Since most of the new files here are coming over from rippled, I started reviewing this by running diff -r -x .git -x build ripple-libpp rippled | less and looking for discrepancies. Obviously, there are a lot of files only in rippled, those are to be expected. There are also a lot of files with differences simply because the corresponding rippled code has changed, which is to be expected in a moving target like this, and can be updated in a later PR, but there were some other problems.
There are still a bunch of files from rippled that don't belong in the library, and aren't used. I pushed a few commits to my https://github.com/ximinez/ripple-libpp/commits/np-RIPD-1469 branch which remove about 250.
I also pushed a few commits to update the default behavior of the test app to run tests by default (it doesn't make much sense to me to require a parameter to do the thing the app is meant to do). I also added some more of the existing test cases into the test app - if the files live in the library, they should be tested. I doubt I got them all. And we can probably get a lot higher than 86.01% test coverage, though it may require writing some new tests to do it.
We are still going to have to decide what to do about some of the dependencies like beast and secp256k1.
Go ahead and check out my changes, and cherry-pick any you don't have problems with into your branch. Please do not squash the commits, though until the review passes.
| @@ -0,0 +1,96 @@ | |||
| #!/bin/bash -u | |||
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 file is a duplicate of the one in bin/ci/ubuntu and should be removed.
| @@ -0,0 +1,82 @@ | |||
| #!/bin/bash -u | |||
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 file is a duplicate of the one in bin/ci/ubuntu and should be removed.
Moved most non-core dependencies into ripple-libpp.