Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

quic: speed up the stateless reset test case #1778

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions p2p/transport/quic/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,14 @@ func testStatelessReset(t *testing.T, tc *connTestCase) {
atomic.StoreUint32(&drop, 1)
ln.Close()
(<-connChan).Close()
// require.NoError(t, ln.Close())
time.Sleep(2000 * time.Millisecond) // give the kernel some time to free the UDP port
ln = runServer(t, serverTransport, fmt.Sprintf("/ip4/127.0.0.1/udp/%d/quic", serverPort))

// The kernel might take a while to free up the UPD port.
// Retry starting the listener until we're successful (with a 3s timeout).
require.Eventually(t, func() bool {
var err error
ln, err = serverTransport.Listen(ma.StringCast(fmt.Sprintf("/ip4/127.0.0.1/udp/%d/quic", serverPort)))
return err == nil
}, 3*time.Second, 50*time.Millisecond)
defer ln.Close()
// Now that the new server is up, re-enable packet forwarding.
atomic.StoreUint32(&drop, 0)
Expand Down