forked from quic-go/quic-go
parse and send the ack_delay_exponent in the transport parameters
This commit is contained in:
@@ -23,8 +23,9 @@ var _ = Describe("Transport Parameters", func() {
|
||||
MaxUniStreams: 7331,
|
||||
IdleTimeout: 42 * time.Second,
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
AckDelayExponent: 14,
|
||||
}
|
||||
Expect(p.String()).To(Equal("&handshake.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 0x1234, InitialMaxStreamDataBidiRemote: 0x2345, InitialMaxStreamDataUni: 0x3456, InitialMaxData: 0x4567, MaxBidiStreams: 1337, MaxUniStreams: 7331, IdleTimeout: 42s}"))
|
||||
Expect(p.String()).To(Equal("&handshake.TransportParameters{OriginalConnectionID: 0xdeadbeef, InitialMaxStreamDataBidiLocal: 0x1234, InitialMaxStreamDataBidiRemote: 0x2345, InitialMaxStreamDataUni: 0x3456, InitialMaxData: 0x4567, MaxBidiStreams: 1337, MaxUniStreams: 7331, IdleTimeout: 42s, AckDelayExponent: 14}"))
|
||||
})
|
||||
|
||||
getRandomValue := func() uint64 {
|
||||
@@ -45,6 +46,7 @@ var _ = Describe("Transport Parameters", func() {
|
||||
DisableMigration: true,
|
||||
StatelessResetToken: bytes.Repeat([]byte{100}, 16),
|
||||
OriginalConnectionID: protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef},
|
||||
AckDelayExponent: 13,
|
||||
}
|
||||
b := &bytes.Buffer{}
|
||||
params.marshal(b)
|
||||
@@ -61,6 +63,7 @@ var _ = Describe("Transport Parameters", func() {
|
||||
Expect(p.DisableMigration).To(Equal(params.DisableMigration))
|
||||
Expect(p.StatelessResetToken).To(Equal(params.StatelessResetToken))
|
||||
Expect(p.OriginalConnectionID).To(Equal(protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef}))
|
||||
Expect(p.AckDelayExponent).To(Equal(uint8(13)))
|
||||
})
|
||||
|
||||
It("errors when the stateless_reset_token has the wrong length", func() {
|
||||
@@ -89,6 +92,22 @@ var _ = Describe("Transport Parameters", func() {
|
||||
Expect(p.unmarshal(b.Bytes(), protocol.PerspectiveServer)).To(MatchError("wrong length for disable_migration: 6 (expected empty)"))
|
||||
})
|
||||
|
||||
It("errors when the ack_delay_exponenent is too large", func() {
|
||||
b := &bytes.Buffer{}
|
||||
(&TransportParameters{AckDelayExponent: 21}).marshal(b)
|
||||
p := &TransportParameters{}
|
||||
Expect(p.unmarshal(b.Bytes(), protocol.PerspectiveServer)).To(MatchError("invalid value for ack_delay_exponent: 21 (maximum 20)"))
|
||||
})
|
||||
|
||||
It("doesn't send the ack_delay_exponent, if it has the default value", func() {
|
||||
b := &bytes.Buffer{}
|
||||
(&TransportParameters{AckDelayExponent: protocol.DefaultAckDelayExponent}).marshal(b)
|
||||
defaultLen := b.Len()
|
||||
b.Reset()
|
||||
(&TransportParameters{AckDelayExponent: protocol.DefaultAckDelayExponent + 1}).marshal(b)
|
||||
Expect(b.Len()).To(Equal(defaultLen + 2 /* parameter ID */ + 2 /* length field */ + 1 /* value */))
|
||||
})
|
||||
|
||||
It("errors when the varint value has the wrong length", func() {
|
||||
b := &bytes.Buffer{}
|
||||
utils.BigEndian.WriteUint16(b, uint16(initialMaxStreamDataBidiLocalParameterID))
|
||||
|
||||
Reference in New Issue
Block a user