-
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
Add RPC error checking support to unit tests #4987
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4987 +/- ##
=========================================
- Coverage 71.0% 71.0% -0.0%
=========================================
Files 796 796
Lines 66727 66727
Branches 10978 10973 -5
=========================================
- Hits 47347 47346 -1
- Misses 19380 19381 +1 |
src/test/jtx/Env_test.cpp
Outdated
@@ -748,8 +748,12 @@ class Env_test : public beast::unit_test::suite | |||
params[jss::fee_mult_max] = 1; | |||
params[jss::fee_div_max] = 2; | |||
// RPC errors result in telENV_RPC_FAILED |
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 feel this comment is more appropriate in src/test/jtx/rpc.h
. Specifically, in the operator()
of the rpc
class.
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 in f58d42d
Co-authored-by: Chenna Keshava B S <21219765+ckeshava@users.noreply.github.com>
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 looks like a good change and the implementation is pretty clever. I spotted a few changes that might be improvements, but feel free to push back on any of them. I put all of my suggestions into a commit that you can see here: https://github.com/scottschurr/rippled/commits/ed-jtx_rpc/ You probably don't want to take all of my suggestions, but the commit will at least show you what I was thinking.
* Make ter and rpcCode optional in ParsedResult * Remove didApply from ParsedResult
* upstream/develop: fix: Remove redundant STAmount conversion in test (4996) fix: resolve database deadlock: (4989) test: verify the rounding behavior of equal-asset AMM deposits (4982) test: Add tests to raise coverage of AMM (4971) chore: Improve codecov coverage reporting (4977) test: Unit test for AMM offer overflow (4986) fix amendment to add `PreviousTxnID`/`PreviousTxnLgrSequence` (4751)
* upstream/develop: Set version to 2.2.0-b3
Proposed commit message:
|
* Remove unused files * Remove packaging scripts * Consolidate external libraries * Simplify protobuf generation * Rename .hpp to .h * Format formerly .hpp files * Rewrite includes $ find src/ripple/ src/test/ -type f -exec sed -i 's:include\s*["<]ripple/\(.*\)\.h\(pp\)\?[">]:include <ripple/\1.h>:' {} + * Fix source lists * Add markers around source lists * Address compiler warnings * Ignore more commits * test: Add RPC error checking support to unit tests (XRPLF#4987) * chore: fix typos (XRPLF#4958) * file * new commit * file sucks --------- Co-authored-by: John Freeman <jfreeman08@gmail.com> Co-authored-by: Pretty Printer <cpp@ripple.com> Co-authored-by: Ed Hennis <ed@ripple.com> Co-authored-by: Snoppy <michaleli@foxmail.com>
High Level Overview of Change
Adds RPC error verification functionality to unit tests. There are two ways to specify the expected result:
error
string, and an optionalerror_exception
detail message. If the detail message is not specified, it will not be checked.These checks are not comprehensive (for example, nothing checks the optional
error_what
field), but I think they are sufficient for any expected test case results.Context of Change
PR #4887 introduced a new
TER
result code to indicate that an RPC request failed during transaction processing, but it does not indicate which RPC failure occurred. Inspired by a discussion on that PR, I added the ability to explicitly check the RPC result.(Props to @ckeshava for the pre-review.)
Type of Change
API Impact
None.
Test Plan
There should be no observable external effects for this change. This is a developer tool to help write more and better unit tests.
Future Tasks
Now that we can distinguish RPC failures, it might be useful to add more test cases that explicitly test the various combinations of failures. (Thanks to @ckeshava again for the suggestion.]