embed the Header in the ExtendedHeader

This commit is contained in:
Marten Seemann 2018-11-25 16:47:29 +07:00
parent af157408de
commit b740d57c61
12 changed files with 306 additions and 244 deletions

View file

@ -22,12 +22,14 @@ var _ = Describe("Packet Handler Map", func() {
getPacket := func(connID protocol.ConnectionID) []byte {
buf := &bytes.Buffer{}
Expect((&wire.ExtendedHeader{
IsLongHeader: true,
Type: protocol.PacketTypeHandshake,
DestConnectionID: connID,
PacketNumberLen: protocol.PacketNumberLen1,
Length: 1,
Version: protocol.VersionWhatever,
Header: wire.Header{
IsLongHeader: true,
DestConnectionID: connID,
Version: protocol.VersionWhatever,
},
Length: 1,
Type: protocol.PacketTypeHandshake,
PacketNumberLen: protocol.PacketNumberLen1,
}).Write(buf, protocol.VersionWhatever)).To(Succeed())
return buf.Bytes()
}
@ -127,12 +129,14 @@ var _ = Describe("Packet Handler Map", func() {
packetHandler.EXPECT().GetVersion().Return(protocol.VersionWhatever)
handler.Add(connID, packetHandler)
hdr := &wire.ExtendedHeader{
IsLongHeader: true,
Type: protocol.PacketTypeHandshake,
Length: 1000,
DestConnectionID: connID,
PacketNumberLen: protocol.PacketNumberLen2,
Version: protocol.VersionWhatever,
Header: wire.Header{
IsLongHeader: true,
DestConnectionID: connID,
Version: protocol.VersionWhatever,
},
Type: protocol.PacketTypeHandshake,
Length: 1000,
PacketNumberLen: protocol.PacketNumberLen2,
}
buf := &bytes.Buffer{}
Expect(hdr.Write(buf, protocol.VersionWhatever)).To(Succeed())
@ -148,12 +152,14 @@ var _ = Describe("Packet Handler Map", func() {
packetHandler.EXPECT().GetVersion().Return(protocol.VersionWhatever)
handler.Add(connID, packetHandler)
hdr := &wire.ExtendedHeader{
IsLongHeader: true,
Type: protocol.PacketTypeHandshake,
Length: 3,
DestConnectionID: connID,
PacketNumberLen: protocol.PacketNumberLen4,
Version: protocol.VersionWhatever,
Header: wire.Header{
IsLongHeader: true,
DestConnectionID: connID,
Version: protocol.VersionWhatever,
},
Type: protocol.PacketTypeHandshake,
Length: 3,
PacketNumberLen: protocol.PacketNumberLen4,
}
buf := &bytes.Buffer{}
Expect(hdr.Write(buf, protocol.VersionWhatever)).To(Succeed())
@ -170,12 +176,14 @@ var _ = Describe("Packet Handler Map", func() {
})
hdr := &wire.ExtendedHeader{
IsLongHeader: true,
Type: protocol.PacketTypeHandshake,
Length: 456,
DestConnectionID: connID,
PacketNumberLen: protocol.PacketNumberLen1,
Version: protocol.VersionWhatever,
Header: wire.Header{
IsLongHeader: true,
DestConnectionID: connID,
Version: protocol.VersionWhatever,
},
Type: protocol.PacketTypeHandshake,
Length: 456,
PacketNumberLen: protocol.PacketNumberLen1,
}
buf := &bytes.Buffer{}
Expect(hdr.Write(buf, protocol.VersionWhatever)).To(Succeed())