mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
protocol: remove VersionWhatever, previously used for testing (#3763)
This commit is contained in:
parent
3ebdd1df5e
commit
f36690ae9c
13 changed files with 43 additions and 48 deletions
|
@ -171,7 +171,7 @@ var _ = Describe("Crypto Stream", func() {
|
|||
})
|
||||
|
||||
It("respects the maximum size", func() {
|
||||
frameHeaderLen := (&wire.CryptoFrame{}).Length(protocol.VersionWhatever)
|
||||
frameHeaderLen := (&wire.CryptoFrame{}).Length(protocol.Version1)
|
||||
_, err := str.Write([]byte("foobar"))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
f := str.PopCryptoFrame(frameHeaderLen + 3)
|
||||
|
|
|
@ -18,12 +18,11 @@ const (
|
|||
|
||||
// The version numbers, making grepping easier
|
||||
const (
|
||||
VersionTLS VersionNumber = 0x1
|
||||
VersionWhatever VersionNumber = math.MaxUint32 - 1 // for when the version doesn't matter
|
||||
VersionUnknown VersionNumber = math.MaxUint32
|
||||
VersionDraft29 VersionNumber = 0xff00001d
|
||||
Version1 VersionNumber = 0x1
|
||||
Version2 VersionNumber = 0x6b3343cf
|
||||
VersionTLS VersionNumber = 0x1
|
||||
VersionUnknown VersionNumber = math.MaxUint32
|
||||
VersionDraft29 VersionNumber = 0xff00001d
|
||||
Version1 VersionNumber = 0x1
|
||||
Version2 VersionNumber = 0x6b3343cf
|
||||
)
|
||||
|
||||
// SupportedVersions lists the versions that the server supports
|
||||
|
@ -43,8 +42,6 @@ func (vn VersionNumber) String() string {
|
|||
}
|
||||
//nolint:exhaustive
|
||||
switch vn {
|
||||
case VersionWhatever:
|
||||
return "whatever"
|
||||
case VersionUnknown:
|
||||
return "unknown"
|
||||
case VersionDraft29:
|
||||
|
|
|
@ -12,7 +12,6 @@ var _ = Describe("Version", func() {
|
|||
|
||||
It("says if a version is valid", func() {
|
||||
Expect(IsValidVersion(VersionTLS)).To(BeTrue())
|
||||
Expect(IsValidVersion(VersionWhatever)).To(BeFalse())
|
||||
Expect(IsValidVersion(VersionUnknown)).To(BeFalse())
|
||||
Expect(IsValidVersion(VersionDraft29)).To(BeTrue())
|
||||
Expect(IsValidVersion(Version1)).To(BeTrue())
|
||||
|
@ -25,7 +24,6 @@ var _ = Describe("Version", func() {
|
|||
})
|
||||
|
||||
It("has the right string representation", func() {
|
||||
Expect(VersionWhatever.String()).To(Equal("whatever"))
|
||||
Expect(VersionUnknown.String()).To(Equal("unknown"))
|
||||
Expect(VersionDraft29.String()).To(Equal("draft-29"))
|
||||
Expect(Version1.String()).To(Equal("v1"))
|
||||
|
|
|
@ -36,7 +36,7 @@ var _ = Describe("DATA_BLOCKED frame", func() {
|
|||
Context("when writing", func() {
|
||||
It("writes a sample frame", func() {
|
||||
frame := DataBlockedFrame{MaximumData: 0xdeadbeef}
|
||||
b, err := frame.Append(nil, protocol.VersionWhatever)
|
||||
b, err := frame.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{dataBlockedFrameType}
|
||||
expected = append(expected, encodeVarInt(0xdeadbeef)...)
|
||||
|
|
|
@ -11,14 +11,14 @@ var _ = Describe("HANDSHAKE_DONE frame", func() {
|
|||
Context("when writing", func() {
|
||||
It("writes a sample frame", func() {
|
||||
frame := HandshakeDoneFrame{}
|
||||
b, err := frame.Append(nil, protocol.VersionWhatever)
|
||||
b, err := frame.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b).To(Equal([]byte{handshakeDoneFrameType}))
|
||||
})
|
||||
|
||||
It("has the correct min length", func() {
|
||||
frame := HandshakeDoneFrame{}
|
||||
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(protocol.ByteCount(1)))
|
||||
Expect(frame.Length(protocol.Version1)).To(Equal(protocol.ByteCount(1)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ var _ = Describe("MAX_STREAM_DATA frame", func() {
|
|||
StreamID: 0x1337,
|
||||
MaximumStreamData: 0xdeadbeef,
|
||||
}
|
||||
Expect(f.Length(protocol.VersionWhatever)).To(Equal(1 + quicvarint.Len(uint64(f.StreamID)) + quicvarint.Len(uint64(f.MaximumStreamData))))
|
||||
Expect(f.Length(protocol.Version1)).To(Equal(1 + quicvarint.Len(uint64(f.StreamID)) + quicvarint.Len(uint64(f.MaximumStreamData))))
|
||||
})
|
||||
|
||||
It("writes a sample frame", func() {
|
||||
|
|
|
@ -17,7 +17,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
It("accepts a frame for a bidirectional stream", func() {
|
||||
data := encodeVarInt(0xdecaf)
|
||||
b := bytes.NewReader(data)
|
||||
f, err := parseMaxStreamsFrame(b, bidiMaxStreamsFrameType, protocol.VersionWhatever)
|
||||
f, err := parseMaxStreamsFrame(b, bidiMaxStreamsFrameType, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.Type).To(Equal(protocol.StreamTypeBidi))
|
||||
Expect(f.MaxStreamNum).To(BeEquivalentTo(0xdecaf))
|
||||
|
@ -27,7 +27,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
It("accepts a frame for a bidirectional stream", func() {
|
||||
data := encodeVarInt(0xdecaf)
|
||||
b := bytes.NewReader(data)
|
||||
f, err := parseMaxStreamsFrame(b, uniMaxStreamsFrameType, protocol.VersionWhatever)
|
||||
f, err := parseMaxStreamsFrame(b, uniMaxStreamsFrameType, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.Type).To(Equal(protocol.StreamTypeUni))
|
||||
Expect(f.MaxStreamNum).To(BeEquivalentTo(0xdecaf))
|
||||
|
@ -37,10 +37,10 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
It("errors on EOFs", func() {
|
||||
const typ = 0x1d
|
||||
data := encodeVarInt(0xdeadbeefcafe13)
|
||||
_, err := parseMaxStreamsFrame(bytes.NewReader(data), typ, protocol.VersionWhatever)
|
||||
_, err := parseMaxStreamsFrame(bytes.NewReader(data), typ, protocol.Version1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
for i := range data {
|
||||
_, err = parseMaxStreamsFrame(bytes.NewReader(data[:i]), typ, protocol.VersionWhatever)
|
||||
_, err = parseMaxStreamsFrame(bytes.NewReader(data[:i]), typ, protocol.Version1)
|
||||
Expect(err).To(MatchError(io.EOF))
|
||||
}
|
||||
})
|
||||
|
@ -53,12 +53,12 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
Type: streamType,
|
||||
MaxStreamNum: protocol.MaxStreamCount,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b)
|
||||
typ, err := quicvarint.Read(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
frame, err := parseMaxStreamsFrame(r, typ, protocol.VersionWhatever)
|
||||
frame, err := parseMaxStreamsFrame(r, typ, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame).To(Equal(f))
|
||||
})
|
||||
|
@ -68,12 +68,12 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
Type: streamType,
|
||||
MaxStreamNum: protocol.MaxStreamCount + 1,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b)
|
||||
typ, err := quicvarint.Read(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
_, err = parseMaxStreamsFrame(r, typ, protocol.VersionWhatever)
|
||||
_, err = parseMaxStreamsFrame(r, typ, protocol.Version1)
|
||||
Expect(err).To(MatchError(fmt.Sprintf("%d exceeds the maximum stream count", protocol.MaxStreamCount+1)))
|
||||
})
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
Type: protocol.StreamTypeBidi,
|
||||
MaxStreamNum: 0xdeadbeef,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{bidiMaxStreamsFrameType}
|
||||
expected = append(expected, encodeVarInt(0xdeadbeef)...)
|
||||
|
@ -97,7 +97,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
Type: protocol.StreamTypeUni,
|
||||
MaxStreamNum: 0xdecafbad,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{uniMaxStreamsFrameType}
|
||||
expected = append(expected, encodeVarInt(0xdecafbad)...)
|
||||
|
@ -106,7 +106,7 @@ var _ = Describe("MAX_STREAMS frame", func() {
|
|||
|
||||
It("has the correct length", func() {
|
||||
frame := MaxStreamsFrame{MaxStreamNum: 0x1337}
|
||||
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(1 + quicvarint.Len(0x1337)))
|
||||
Expect(frame.Length(protocol.Version1)).To(Equal(1 + quicvarint.Len(0x1337)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -18,7 +18,7 @@ var _ = Describe("NEW_TOKEN frame", func() {
|
|||
data := encodeVarInt(uint64(len(token)))
|
||||
data = append(data, token...)
|
||||
b := bytes.NewReader(data)
|
||||
f, err := parseNewTokenFrame(b, protocol.VersionWhatever)
|
||||
f, err := parseNewTokenFrame(b, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(string(f.Token)).To(Equal(token))
|
||||
Expect(b.Len()).To(BeZero())
|
||||
|
@ -27,7 +27,7 @@ var _ = Describe("NEW_TOKEN frame", func() {
|
|||
It("rejects empty tokens", func() {
|
||||
data := encodeVarInt(0)
|
||||
b := bytes.NewReader(data)
|
||||
_, err := parseNewTokenFrame(b, protocol.VersionWhatever)
|
||||
_, err := parseNewTokenFrame(b, protocol.Version1)
|
||||
Expect(err).To(MatchError("token must not be empty"))
|
||||
})
|
||||
|
||||
|
@ -36,10 +36,10 @@ var _ = Describe("NEW_TOKEN frame", func() {
|
|||
data := encodeVarInt(uint64(len(token)))
|
||||
data = append(data, token...)
|
||||
r := bytes.NewReader(data)
|
||||
_, err := parseNewTokenFrame(r, protocol.VersionWhatever)
|
||||
_, err := parseNewTokenFrame(r, protocol.Version1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
for i := range data {
|
||||
_, err := parseNewTokenFrame(bytes.NewReader(data[:i]), protocol.VersionWhatever)
|
||||
_, err := parseNewTokenFrame(bytes.NewReader(data[:i]), protocol.Version1)
|
||||
Expect(err).To(MatchError(io.EOF))
|
||||
}
|
||||
})
|
||||
|
@ -49,7 +49,7 @@ var _ = Describe("NEW_TOKEN frame", func() {
|
|||
It("writes a sample frame", func() {
|
||||
token := "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
|
||||
f := &NewTokenFrame{Token: []byte(token)}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{newTokenFrameType}
|
||||
expected = append(expected, encodeVarInt(uint64(len(token)))...)
|
||||
|
@ -59,7 +59,7 @@ var _ = Describe("NEW_TOKEN frame", func() {
|
|||
|
||||
It("has the correct min length", func() {
|
||||
frame := &NewTokenFrame{Token: []byte("foobar")}
|
||||
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(1 + quicvarint.Len(6) + 6))
|
||||
Expect(frame.Length(protocol.Version1)).To(Equal(1 + quicvarint.Len(6) + 6))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -14,7 +14,7 @@ var _ = Describe("PATH_CHALLENGE frame", func() {
|
|||
Context("when parsing", func() {
|
||||
It("accepts sample frame", func() {
|
||||
b := bytes.NewReader([]byte{1, 2, 3, 4, 5, 6, 7, 8})
|
||||
f, err := parsePathChallengeFrame(b, protocol.VersionWhatever)
|
||||
f, err := parsePathChallengeFrame(b, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(BeZero())
|
||||
Expect(f.Data).To(Equal([8]byte{1, 2, 3, 4, 5, 6, 7, 8}))
|
||||
|
@ -35,14 +35,14 @@ var _ = Describe("PATH_CHALLENGE frame", func() {
|
|||
Context("when writing", func() {
|
||||
It("writes a sample frame", func() {
|
||||
frame := PathChallengeFrame{Data: [8]byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}}
|
||||
b, err := frame.Append(nil, protocol.VersionWhatever)
|
||||
b, err := frame.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b).To(Equal([]byte{pathChallengeFrameType, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}))
|
||||
})
|
||||
|
||||
It("has the correct length", func() {
|
||||
frame := PathChallengeFrame{}
|
||||
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(protocol.ByteCount(9)))
|
||||
Expect(frame.Length(protocol.Version1)).To(Equal(protocol.ByteCount(9)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -14,7 +14,7 @@ var _ = Describe("PATH_RESPONSE frame", func() {
|
|||
Context("when parsing", func() {
|
||||
It("accepts sample frame", func() {
|
||||
b := bytes.NewReader([]byte{1, 2, 3, 4, 5, 6, 7, 8})
|
||||
f, err := parsePathResponseFrame(b, protocol.VersionWhatever)
|
||||
f, err := parsePathResponseFrame(b, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(BeZero())
|
||||
Expect(f.Data).To(Equal([8]byte{1, 2, 3, 4, 5, 6, 7, 8}))
|
||||
|
@ -34,14 +34,14 @@ var _ = Describe("PATH_RESPONSE frame", func() {
|
|||
Context("when writing", func() {
|
||||
It("writes a sample frame", func() {
|
||||
frame := PathResponseFrame{Data: [8]byte{0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}}
|
||||
b, err := frame.Append(nil, protocol.VersionWhatever)
|
||||
b, err := frame.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b).To(Equal([]byte{pathResponseFrameType, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0x13, 0x37}))
|
||||
})
|
||||
|
||||
It("has the correct length", func() {
|
||||
frame := PathResponseFrame{}
|
||||
Expect(frame.Length(protocol.VersionWhatever)).To(Equal(protocol.ByteCount(9)))
|
||||
Expect(frame.Length(protocol.Version1)).To(Equal(protocol.ByteCount(9)))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -17,7 +17,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
|
|||
It("accepts a frame for bidirectional streams", func() {
|
||||
expected := encodeVarInt(0x1337)
|
||||
b := bytes.NewReader(expected)
|
||||
f, err := parseStreamsBlockedFrame(b, bidiStreamBlockedFrameType, protocol.VersionWhatever)
|
||||
f, err := parseStreamsBlockedFrame(b, bidiStreamBlockedFrameType, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.Type).To(Equal(protocol.StreamTypeBidi))
|
||||
Expect(f.StreamLimit).To(BeEquivalentTo(0x1337))
|
||||
|
@ -27,7 +27,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
|
|||
It("accepts a frame for unidirectional streams", func() {
|
||||
expected := encodeVarInt(0x7331)
|
||||
b := bytes.NewReader(expected)
|
||||
f, err := parseStreamsBlockedFrame(b, uniStreamBlockedFrameType, protocol.VersionWhatever)
|
||||
f, err := parseStreamsBlockedFrame(b, uniStreamBlockedFrameType, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.Type).To(Equal(protocol.StreamTypeUni))
|
||||
Expect(f.StreamLimit).To(BeEquivalentTo(0x7331))
|
||||
|
@ -53,12 +53,12 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
|
|||
Type: streamType,
|
||||
StreamLimit: protocol.MaxStreamCount,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b)
|
||||
typ, err := quicvarint.Read(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
frame, err := parseStreamsBlockedFrame(r, typ, protocol.VersionWhatever)
|
||||
frame, err := parseStreamsBlockedFrame(r, typ, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame).To(Equal(f))
|
||||
})
|
||||
|
@ -68,12 +68,12 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
|
|||
Type: streamType,
|
||||
StreamLimit: protocol.MaxStreamCount + 1,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b)
|
||||
typ, err := quicvarint.Read(r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
_, err = parseStreamsBlockedFrame(r, typ, protocol.VersionWhatever)
|
||||
_, err = parseStreamsBlockedFrame(r, typ, protocol.Version1)
|
||||
Expect(err).To(MatchError(fmt.Sprintf("%d exceeds the maximum stream count", protocol.MaxStreamCount+1)))
|
||||
})
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
|
|||
Type: protocol.StreamTypeBidi,
|
||||
StreamLimit: 0xdeadbeefcafe,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{bidiStreamBlockedFrameType}
|
||||
expected = append(expected, encodeVarInt(0xdeadbeefcafe)...)
|
||||
|
@ -97,7 +97,7 @@ var _ = Describe("STREAMS_BLOCKED frame", func() {
|
|||
Type: protocol.StreamTypeUni,
|
||||
StreamLimit: 0xdeadbeefcafe,
|
||||
}
|
||||
b, err := f.Append(nil, protocol.VersionWhatever)
|
||||
b, err := f.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
expected := []byte{uniStreamBlockedFrameType}
|
||||
expected = append(expected, encodeVarInt(0xdeadbeefcafe)...)
|
||||
|
|
|
@ -43,7 +43,7 @@ var _ = Describe("Packet Handler Map", func() {
|
|||
Version: protocol.VersionTLS,
|
||||
},
|
||||
PacketNumberLen: protocol.PacketNumberLen2,
|
||||
}).Append(nil, protocol.VersionWhatever)
|
||||
}).Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
return b
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ var _ = Describe("Send Stream", func() {
|
|||
StreamID: streamID,
|
||||
Offset: offset,
|
||||
DataLenPresent: true,
|
||||
}).Length(protocol.VersionWhatever)
|
||||
}).Length(protocol.Version1)
|
||||
}
|
||||
|
||||
waitForWrite := func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue