send a reserved version number in version negotiation packets

This commit is contained in:
Marten Seemann 2017-11-30 11:54:49 +07:00
parent 1f5cd31569
commit be29963637
6 changed files with 43 additions and 16 deletions

View file

@ -16,7 +16,11 @@ var _ = Describe("Version Negotiation Packets", func() {
Expect(err).ToNot(HaveOccurred())
Expect(hdr.VersionFlag).To(BeTrue())
Expect(hdr.ConnectionID).To(Equal(protocol.ConnectionID(0x1337)))
Expect(hdr.SupportedVersions).To(Equal(versions))
// the supported versions should include one reserved version number
Expect(hdr.SupportedVersions).To(HaveLen(len(versions) + 1))
for _, version := range versions {
Expect(hdr.SupportedVersions).To(ContainElement(version))
}
})
It("writes in IETF draft style", func() {
@ -27,6 +31,11 @@ var _ = Describe("Version Negotiation Packets", func() {
Expect(hdr.IsVersionNegotiation).To(BeTrue())
Expect(hdr.ConnectionID).To(Equal(protocol.ConnectionID(0x1337)))
Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(0x42)))
Expect(hdr.SupportedVersions).To(Equal(versions))
Expect(hdr.Version).To(BeZero())
// the supported versions should include one reserved version number
Expect(hdr.SupportedVersions).To(HaveLen(len(versions) + 1))
for _, version := range versions {
Expect(hdr.SupportedVersions).To(ContainElement(version))
}
})
})