introduce a test helper function to create a UDP socket on localhost (#4756)

This commit is contained in:
Marten Seemann
2024-12-17 23:30:00 +08:00
committed by GitHub
parent 8cb88ee145
commit 3886be4e95
29 changed files with 499 additions and 680 deletions

View File

@@ -69,19 +69,14 @@ func testStatelessReset(t *testing.T, connIDLen int) {
require.NoError(t, err)
defer proxy.Close()
addr, err := net.ResolveUDPAddr("udp", "localhost:0")
require.NoError(t, err)
udpConn, err := net.ListenUDP("udp", addr)
require.NoError(t, err)
defer udpConn.Close()
cl := &quic.Transport{
Conn: udpConn,
Conn: newUPDConnLocalhost(t),
ConnectionIDLength: connIDLen,
}
defer cl.Close()
conn, err := cl.Dial(
context.Background(),
&net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: proxy.LocalPort()},
proxy.LocalAddr(),
getTLSClientConfig(),
getQuicConfig(&quic.Config{MaxIdleTimeout: 2 * time.Second}),
)