Skip to content

test(p2p): wait for the first peer before dialing the duplicate-IP one - #6457

Open
thehowl wants to merge 1 commit into
gnolang:masterfrom
thehowl:dev/morgan/p2p-duplicate-ip-test-flake
Open

thehowl wants to merge 1 commit into
gnolang:masterfrom
thehowl:dev/morgan/p2p-duplicate-ip-test-flake

Conversation

@thehowl

@thehowl thehowl commented Nov 6, 2026

Copy link
Copy Markdown
Member

TestSwitchClosesRejectedDuplicateIPConn flakes in ci / tm2, failing with switch_duplicate_ip_test.go:163: the rejected connection was left open by the switch after a 10s timeout. Recent hits on unrelated branches: 40308030247, 38332122105, 37707941642.

The test assumes the first connection reaches the switch first. MultiplexTransport handshakes each inbound connection in its own goroutine and hands it to the switch in completion order, so the second connection can take the IP's only slot. The first one is then rejected, but the test only watches the second one's error channel, so it waits until the timeout. The switch behaves correctly; the test is wrong about the order.

The fix waits for the first peer to occupy the slot before dialing the second, the same wait TestSwitchClosesRejectedOverCapacityConn already has ("or the second may beat it there").

Testing: I ran the real test function as 2000 parallel subtests (-cpu 4), pinned to one core shared with 3 busy loops:

failed
before 63 / 2000
after 0 / 2000

go test ./tm2/pkg/p2p/ passes, and so do the duplicate-IP tests run with -race -count=20.

Test-only change; written with AI assistance and reviewed by me.

TestSwitchClosesRejectedDuplicateIPConn assumed the first connection
reaches the switch first. The transport handshakes each inbound connection
in its own goroutine and hands it over in completion order, so the second
can take the IP's only slot instead. The first is then the one rejected,
nobody watches its error channel, and the test times out after 10s with
"the rejected connection was left open by the switch".

Wait for the first to occupy the slot, as
TestSwitchClosesRejectedOverCapacityConn already does.
@Gno2D2

Gno2D2 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: thehowl/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📦 🌐 tendermint v2 Issues or PRs tm2 related

Projects

Development

Successfully merging this pull request may close these issues.

2 participants