forked from quic-go/quic-go
add support for the version negotiation test
This commit is contained in:
@@ -9,8 +9,10 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/http3"
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/interop/http09"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@@ -49,6 +51,8 @@ func runTestcase(testcase string) error {
|
||||
defer r.Close()
|
||||
return downloadFiles(r, urls)
|
||||
case "handshake", "transfer", "retry":
|
||||
case "versionnegotiation":
|
||||
return runVersionNegotiationTest(urls)
|
||||
case "resumption":
|
||||
return runResumptionTest(urls)
|
||||
default:
|
||||
@@ -62,6 +66,21 @@ func runTestcase(testcase string) error {
|
||||
return downloadFiles(r, urls)
|
||||
}
|
||||
|
||||
func runVersionNegotiationTest(urls []string) error {
|
||||
if len(urls) != 1 {
|
||||
return errors.New("expected at least 2 URLs")
|
||||
}
|
||||
protocol.SupportedVersions = []protocol.VersionNumber{0x1a2a3a4a}
|
||||
err := downloadFile(&http09.RoundTripper{}, urls[0])
|
||||
if err == nil {
|
||||
return errors.New("expected version negotiation to fail")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "No compatible QUIC version found") {
|
||||
return fmt.Errorf("expect version negotiation error, got: %s", err.Error())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func runResumptionTest(urls []string) error {
|
||||
if len(urls) < 2 {
|
||||
return errors.New("expected at least 2 URLs")
|
||||
|
||||
@@ -30,7 +30,7 @@ func main() {
|
||||
}
|
||||
|
||||
switch testcase {
|
||||
case "handshake", "transfer", "resumption":
|
||||
case "versionnegotiation", "handshake", "transfer", "resumption":
|
||||
err = runHTTP09Server(quicConf)
|
||||
case "retry":
|
||||
// By default, quic-go performs a Retry on every incoming connection.
|
||||
|
||||
Reference in New Issue
Block a user