golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/quic/config_test.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build go1.21 6 7 package quic 8 9 import "testing" 10 11 func TestConfigTransportParameters(t *testing.T) { 12 const ( 13 wantInitialMaxData = int64(1) 14 wantInitialMaxStreamData = int64(2) 15 wantInitialMaxStreamsBidi = int64(3) 16 wantInitialMaxStreamsUni = int64(4) 17 ) 18 tc := newTestConn(t, clientSide, func(c *Config) { 19 c.MaxBidiRemoteStreams = wantInitialMaxStreamsBidi 20 c.MaxUniRemoteStreams = wantInitialMaxStreamsUni 21 c.MaxStreamReadBufferSize = wantInitialMaxStreamData 22 c.MaxConnReadBufferSize = wantInitialMaxData 23 }) 24 tc.handshake() 25 if tc.sentTransportParameters == nil { 26 t.Fatalf("conn didn't send transport parameters during handshake") 27 } 28 p := tc.sentTransportParameters 29 if got, want := p.initialMaxData, wantInitialMaxData; got != want { 30 t.Errorf("initial_max_data = %v, want %v", got, want) 31 } 32 if got, want := p.initialMaxStreamDataBidiLocal, wantInitialMaxStreamData; got != want { 33 t.Errorf("initial_max_stream_data_bidi_local = %v, want %v", got, want) 34 } 35 if got, want := p.initialMaxStreamDataBidiRemote, wantInitialMaxStreamData; got != want { 36 t.Errorf("initial_max_stream_data_bidi_remote = %v, want %v", got, want) 37 } 38 if got, want := p.initialMaxStreamDataUni, wantInitialMaxStreamData; got != want { 39 t.Errorf("initial_max_stream_data_uni = %v, want %v", got, want) 40 } 41 if got, want := p.initialMaxStreamsBidi, wantInitialMaxStreamsBidi; got != want { 42 t.Errorf("initial_max_stream_data_uni = %v, want %v", got, want) 43 } 44 if got, want := p.initialMaxStreamsUni, wantInitialMaxStreamsUni; got != want { 45 t.Errorf("initial_max_stream_data_uni = %v, want %v", got, want) 46 } 47 }