-
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 unit test for get_counts RPC method (RIPD-1399) #2011
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2011 +/- ##
===========================================
+ Coverage 67.25% 67.54% +0.29%
===========================================
Files 683 683
Lines 49231 49231
===========================================
+ Hits 33111 33255 +144
+ Misses 16120 15976 -144
Continue to review full report at Codecov.
|
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.
👍
src/test/rpc/GetCounts_test.cpp
Outdated
BEAST_EXPECT(jrr[jss::status] == "success"); | ||
BEAST_EXPECT(! jrr.isMember("Transaction")); | ||
BEAST_EXPECT(! jrr.isMember("STObject")); | ||
BEAST_EXPECT(! jrr.isMember("HashRouterEntry")); |
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.
How did you decide which fields to look for?
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 looked for counted objects in the subsequent request (after there are some actual counts reported) and then just verified that those same fields are not present in this initial request. This is definitely not exhaustive and probably could be improved.
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.
Seems reasonable to me since the RPC doesn't guarantee much.
src/test/rpc/GetCounts_test.cpp
Outdated
BEAST_EXPECT(jrr[jss::status] == "success"); | ||
BEAST_EXPECT( | ||
jrr.isMember("Transaction") && | ||
jrr["Transaction"].asInt() > 0); |
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'm a little surprised that you're using > 0
comparisons. Since you have complete control of the environment shouldn't most of these values be repeatable? I'm just surprised, not necessarily objecting.
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.
These are "counted objects" which I didn't feel I had direct enough control over to warrant an exact check. That said, I can very likely access the CountedObjects
singleton and validate directly -- do you think that would worthwhile?
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.
Hmmm. I'm a little surprised that you don't think the CountedObjects
are predicable enough to give reliable results. But I've never looked at them very hard. I certainly accept your assessment.
Interesting thought about comparing to the CountedObject
values. It would not be worth heroic efforts to have an exact value to compare against. But if it's relatively easy to do it might be nice. Your call.
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.
What's here looks good to me. 👍
src/test/rpc/GetCounts_test.cpp
Outdated
BEAST_EXPECT(jrr[jss::status] == "success"); | ||
BEAST_EXPECT( | ||
jrr.isMember("Transaction") && | ||
jrr["Transaction"].asInt() > 0); |
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.
Hmmm. I'm a little surprised that you don't think the CountedObjects
are predicable enough to give reliable results. But I've never looked at them very hard. I certainly accept your assessment.
Interesting thought about comparing to the CountedObject
values. It would not be worth heroic efforts to have an exact value to compare against. But if it's relatively easy to do it might be nice. Your call.
Nice! Revised tests look even better. 👍 |
In 0.60.0-b7 |
No description provided.