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
test: expand LimitOrphan and EraseForPeer coverage #30082
base: master
Are you sure you want to change the base?
test: expand LimitOrphan and EraseForPeer coverage #30082
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. |
src/test/orphanage_tests.cpp
Outdated
// Jump ORPHAN_TX_EXPIRE_TIME minutes, orphan should be timed out on limiting | ||
SetMockTime(GetTime() + 20 * 60); | ||
BOOST_CHECK_EQUAL(orphanage.CountOrphans(), 1); | ||
orphanage.LimitOrphans(1, rng); | ||
BOOST_CHECK_EQUAL(orphanage.CountOrphans(), 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.
Maybe out of scope but I wonder if it would be best to add a current_time
parameter to the TxOrphanage
methods to make it easier to test and fuzz the expiration (also should have a test for the sorting for GetChildrenFromSamePeer
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.
probably a good idea, though you might have better opinions on orphanage interface. I tightened the time testing a bit more by setting mocktime at beginning, then checking boundary conditions via subsequent setting of the time.
bb2389a
to
dd7bf60
Compare
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.
lgtm
orphanage.LimitOrphans(1, rng); | ||
BOOST_CHECK_EQUAL(orphanage.CountOrphans(), 1); | ||
|
||
// Jump ORPHAN_TX_EXPIRE_TIME minutes, orphan should be timed out on limiting |
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.
Note you've only jumped 1 second here
BOOST_CHECK_EQUAL(orphanage.CountOrphans(), 1); | ||
|
||
// One second shy of expiration | ||
SetMockTime(now - 1 + 20 * 60); |
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.
Would be nice if the constants were moved to txorphanage.h so we don't need the magic number here. Could be useful in other tests as well.
Inspired by refactorings in #30000 as the coverage appeared a bit sparse.
Added some minimal border value testing, timeouts, and tightened existing assertions.