forked from quic-go/quic-go
introduce a test helper function to create a UDP socket on localhost (#4756)
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"strconv"
|
||||
@@ -21,6 +22,8 @@ import (
|
||||
"github.com/quic-go/quic-go/internal/protocol"
|
||||
"github.com/quic-go/quic-go/internal/wire"
|
||||
"github.com/quic-go/quic-go/logging"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const alpn = tools.ALPN
|
||||
@@ -150,6 +153,14 @@ func addTracer(tr *quic.Transport) {
|
||||
)
|
||||
}
|
||||
|
||||
func newUPDConnLocalhost(t testing.TB) *net.UDPConn {
|
||||
t.Helper()
|
||||
conn, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 0})
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { conn.Close() })
|
||||
return conn
|
||||
}
|
||||
|
||||
func areHandshakesRunning() bool {
|
||||
var b bytes.Buffer
|
||||
pprof.Lookup("goroutine").WriteTo(&b, 1)
|
||||
|
||||
Reference in New Issue
Block a user