Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

instagibbs
Copy link
Member

Inspired by refactorings in #30000 as the coverage appeared a bit sparse.

Added some minimal border value testing, timeouts, and tightened existing assertions.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 10, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

src/test/orphanage_tests.cpp Outdated Show resolved Hide resolved
src/test/orphanage_tests.cpp Outdated Show resolved Hide resolved
Comment on lines 207 to 212
// 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);
Copy link
Member

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)

Copy link
Member Author

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.

@instagibbs instagibbs force-pushed the 2024-05-orphan_limit_eraseforpeer branch from bb2389a to dd7bf60 Compare May 13, 2024 16:41
Copy link
Member

@glozow glozow left a 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
Copy link
Member

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);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants