chore: optimize slow net tests - #7363
Draft
cylewitruk-stacks wants to merge 6 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces runtime and flakiness in stackslib networking tests by replacing wall-clock sleeps/long polls with deterministic state aging and shorter poll timeouts, while preserving production code paths and assertions.
Changes:
- Added
TestPeerstepping helpers that accept a custom poll timeout, and updated many in-process net tests to use short polls. - Reworked multiple tests to advance internal timestamps/state directly (neighbor-walk, heartbeat, disconnect-unresponsive, bandwidth stats) instead of sleeping.
- Reduced oversized fixtures (notably mempool pagination) and removed unnecessary Nakamoto fixture bootstrapping from tests that don’t need it; refactored
update_highest_stacks_neighborlogic for more direct unit testing.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| stackslib/src/util_lib/mod.rs | Updates with_timeout to use recv_timeout instead of a sleep/poll loop. |
| stackslib/src/net/tests/relay/nakamoto.rs | Uses short-poll stepping in relay tests; removes unnecessary Nakamoto fixture setup in buffer/direct-handler tests. |
| stackslib/src/net/tests/neighbors.rs | Introduces short-poll stepping helpers and deterministic timestamp aging to eliminate long sleeps. |
| stackslib/src/net/tests/mod.rs | Splits update_highest_stacks_neighbor coverage into pure logic tests plus a node-state smoke test. |
| stackslib/src/net/tests/mempool/mod.rs | Shrinks pagination fixture size and enforces pagination via a reduced mempool_max_tx_query; short-poll stepping. |
| stackslib/src/net/tests/inv/nakamoto.rs | Shortens in-process peer stepping polls for inventory sync tests. |
| stackslib/src/net/tests/inv/epoch2x.rs | Uses short-poll stepping in epoch2x inventory tests. |
| stackslib/src/net/tests/httpcore.rs | Simplifies mock server teardown by closing immediately after responding (no client-done channel). |
| stackslib/src/net/tests/download/nakamoto.rs | Uses short-poll stepping/run loops to speed download tests. |
| stackslib/src/net/server.rs | Shortens polling and reduces connect-timeout waits in HTTP server tests. |
| stackslib/src/net/p2p.rs | Removes long sleeps by directly aging connection timestamps in disconnect_unresponsive test. |
| stackslib/src/net/mod.rs | Extracts update_highest_stacks_neighbor_value and adds TestPeer timeout-aware stepping APIs. |
| stackslib/src/net/chat.rs | Replaces sleep-based bandwidth tests with deterministic timestamp population; consolidates repeated tests via a macro. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 28606722758Coverage increased (+0.5%) to 86.216%Details
Uncovered Changes
Coverage Regressions9165 previously-covered lines in 139 files lost coverage.
Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR speeds up a set of slow networking tests by replacing artificial wall-clock waits with natural progressions and shrinking oversized fixtures, while preserving the production paths and assertions being exercised:
TestPeerhelpers so tests can avoid repeated 100ms idle polls without changing default behavior.update_highest_stacks_neighborcoverage into a fast pure-rule matrix plus one wrapper smoke test throughStacksNodeState.with_timeoutto use channelrecv_timeoutinstead of a sleep/poll loop.