test(p2p): cover the timer branch of waitForDialTime - #6067
Open
tbruyelle wants to merge 3 commits into
Open
Conversation
The dial loop parks on waitForDialTime, which wakes on three things: the context, a newly queued item, and the timer that fires when the queue head becomes due. The first two are covered. The third was not, and the gap was invisible: removing 'case <-timer.C:' left the whole p2p package green. That branch is not cosmetic. Without it a backed off item is never dialed when its time comes, so the loop parks until something else is queued or the node shuts down, and persistent peer backoff silently stops retrying. The new subtest queues a single item due shortly, with nothing else queued and a live context, so the timer is the only thing that can bring the loop back. It fails against a build with that case removed, and the other two subtests still pass there, so it is the one carrying the guarantee. Reported by AviaOne while reviewing gnolang#6054.
Collaborator
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
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.
Description
Follow-up to #6054, from AviaOne's review. The test is theirs; I folded it in as a subtest and verified it.
runDialLoopparks onwaitForDialTime, which wakes on three things:The timer branch had no coverage, and the gap was invisible — removing
case <-timer.C:left the entire package green:That branch is not cosmetic. Without it, a backed off item is never dialed once it becomes due: the loop parks until something else is queued or the node shuts down, so persistent peer backoff silently stops retrying. It is the behaviour #6054 exists to provide.
The test
Added as a third subtest of
TestMultiplexSwitch_DialLoop_BackedOff, so the three subtests now map one to one onto the threeselectbranches.A single item is queued, due shortly, with nothing else in the queue and a live context — so the timer is the only thing that can bring the loop back.
Verification
Mutation checked in both directions:
DoesNotSpincase <-timer.C:removedmasterSo the subtest is the one carrying the guarantee, and nothing else in the suite notices that branch going missing. Passing run repeated with
-count=3;gofmt,go vetand./tm2/pkg/p2p/...all clean.Test-only, so no ADR per
AGENTS.md.Drafted with AI assistance (Claude Code). I have reviewed the change and the verification and stand behind them.