diff --git a/h2quic/integration_test.go b/h2quic/integration_test.go index a39bad39e..8c13d59f7 100644 --- a/h2quic/integration_test.go +++ b/h2quic/integration_test.go @@ -5,13 +5,13 @@ import ( "crypto/rand" "fmt" "io" + "net" "net/http" "os" "os/exec" "runtime" "strconv" "sync" - "time" "github.com/lucas-clemente/quic-go/h2quic" "github.com/lucas-clemente/quic-go/protocol" @@ -26,16 +26,14 @@ import ( ) var _ = Describe("Integration tests", func() { - const port = "6729" - const host = "127.0.0.1" - const addr = host + ":" + port - const dataLen = 50 * 1024 + const host = "127.0.0.1" var ( server *h2quic.Server clientPath string data []byte + port string ) http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { @@ -60,17 +58,23 @@ var _ = Describe("Integration tests", func() { os.Getenv("GOPATH"), runtime.GOOS, ) + server = &h2quic.Server{ Server: &http.Server{ - Addr: addr, TLSConfig: testdata.GetTLSConfig(), }, } + + addr, err := net.ResolveUDPAddr("udp", host+":0") + Expect(err).NotTo(HaveOccurred()) + conn, err := net.ListenUDP("udp", addr) + Expect(err).NotTo(HaveOccurred()) + port = strconv.Itoa(conn.LocalAddr().(*net.UDPAddr).Port) + go func() { defer GinkgoRecover() - server.ListenAndServe() + server.Serve(conn) }() - time.Sleep(10 * time.Millisecond) }) AfterSuite(func() { diff --git a/h2quic/server.go b/h2quic/server.go index 72764f3aa..6496cbc32 100644 --- a/h2quic/server.go +++ b/h2quic/server.go @@ -60,7 +60,7 @@ func (s *Server) ListenAndServeTLS(certFile, keyFile string) error { return s.serveImpl(config, nil) } -// Serve an existing udp conn +// Serve an existing UDP connection. func (s *Server) Serve(conn *net.UDPConn) error { return s.serveImpl(s.TLSConfig, conn) }