rename packet packing functions in the packet packer

This commit is contained in:
Marten Seemann 2020-02-13 17:18:19 +07:00
parent 5aad7cae5d
commit 29b784e782
5 changed files with 73 additions and 73 deletions

View file

@ -78,19 +78,19 @@ func (mr *MockPackerMockRecorder) MaybePackProbePacket(arg0 interface{}) *gomock
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePackProbePacket", reflect.TypeOf((*MockPacker)(nil).MaybePackProbePacket), arg0)
}
// PackAppDataPacket mocks base method
func (m *MockPacker) PackAppDataPacket() (*packedPacket, error) {
// PackCoalescedPacket mocks base method
func (m *MockPacker) PackCoalescedPacket() (*coalescedPacket, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PackAppDataPacket")
ret0, _ := ret[0].(*packedPacket)
ret := m.ctrl.Call(m, "PackCoalescedPacket")
ret0, _ := ret[0].(*coalescedPacket)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// PackAppDataPacket indicates an expected call of PackAppDataPacket
func (mr *MockPackerMockRecorder) PackAppDataPacket() *gomock.Call {
// PackCoalescedPacket indicates an expected call of PackCoalescedPacket
func (mr *MockPackerMockRecorder) PackCoalescedPacket() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackAppDataPacket", reflect.TypeOf((*MockPacker)(nil).PackAppDataPacket))
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackCoalescedPacket", reflect.TypeOf((*MockPacker)(nil).PackCoalescedPacket))
}
// PackConnectionClose mocks base method
@ -109,10 +109,10 @@ func (mr *MockPackerMockRecorder) PackConnectionClose(arg0 interface{}) *gomock.
}
// PackPacket mocks base method
func (m *MockPacker) PackPacket() (*coalescedPacket, error) {
func (m *MockPacker) PackPacket() (*packedPacket, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PackPacket")
ret0, _ := ret[0].(*coalescedPacket)
ret0, _ := ret[0].(*packedPacket)
ret1, _ := ret[1].(error)
return ret0, ret1
}

View file

@ -15,8 +15,8 @@ import (
)
type packer interface {
PackPacket() (*coalescedPacket, error)
PackAppDataPacket() (*packedPacket, error)
PackCoalescedPacket() (*coalescedPacket, error)
PackPacket() (*packedPacket, error)
MaybePackProbePacket(protocol.EncryptionLevel) (*packedPacket, error)
MaybePackAckPacket(handshakeConfirmed bool) (*packedPacket, error)
PackConnectionClose(*wire.ConnectionCloseFrame) (*packedPacket, error)
@ -264,10 +264,10 @@ func (p *packetPacker) MaybePackAckPacket(handshakeConfirmed bool) (*packedPacke
return p.writeSinglePacket(hdr, payload, encLevel, sealer)
}
// PackPacket packs a new packet.
// PackCoalescedPacket packs a new packet.
// It packs an Initial / Handshake if there is data to send in these packet number spaces.
// It should only be called before the handshake is confirmed.
func (p *packetPacker) PackPacket() (*coalescedPacket, error) {
func (p *packetPacker) PackCoalescedPacket() (*coalescedPacket, error) {
buffer := getPacketBuffer()
packet, err := p.packCoalescedPacket(buffer)
if err != nil {
@ -324,9 +324,9 @@ func (p *packetPacker) packCoalescedPacket(buffer *packetBuffer) (*coalescedPack
return packet, nil
}
// PackAppDataPacket packs a packet in the application data packet number space.
// PackPacket packs a packet in the application data packet number space.
// It should be called after the handshake is confirmed.
func (p *packetPacker) PackAppDataPacket() (*packedPacket, error) {
func (p *packetPacker) PackPacket() (*packedPacket, error) {
buffer := getPacketBuffer()
contents, err := p.maybeAppendAppDataPacket(buffer)
if err != nil || contents == nil {

View file

@ -175,7 +175,7 @@ var _ = Describe("Packet packer", func() {
expectAppendControlFrames()
f := &wire.StreamFrame{Data: []byte{0xde, 0xca, 0xfb, 0xad}}
expectAppendStreamFrames(ackhandler.Frame{Frame: f})
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p).ToNot(BeNil())
Expect(p.packets).To(HaveLen(1))
@ -265,7 +265,7 @@ var _ = Describe("Packet packer", func() {
framer.EXPECT().AppendStreamFrames(gomock.Any(), gomock.Any()).DoAndReturn(func(frames []ackhandler.Frame, _ protocol.ByteCount) ([]ackhandler.Frame, protocol.ByteCount) {
return frames, 0
})
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
@ -290,7 +290,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
framer.EXPECT().AppendControlFrames(nil, gomock.Any())
framer.EXPECT().AppendStreamFrames(nil, gomock.Any())
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(p).To(BeNil())
Expect(err).ToNot(HaveOccurred())
})
@ -306,7 +306,7 @@ var _ = Describe("Packet packer", func() {
Data: []byte{0xde, 0xca, 0xfb, 0xad},
}
expectAppendStreamFrames(ackhandler.Frame{Frame: f})
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p).ToNot(BeNil())
b := &bytes.Buffer{}
@ -325,7 +325,7 @@ var _ = Describe("Packet packer", func() {
StreamID: 5,
Data: []byte("foobar"),
}})
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.EncryptionLevel()).To(Equal(protocol.Encryption1RTT))
})
@ -338,7 +338,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
expectAppendControlFrames()
expectAppendStreamFrames()
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(err).NotTo(HaveOccurred())
Expect(p).ToNot(BeNil())
Expect(p.ack).To(Equal(ack))
@ -370,7 +370,7 @@ var _ = Describe("Packet packer", func() {
}
expectAppendControlFrames(frames...)
expectAppendStreamFrames()
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.frames).To(Equal(frames))
@ -392,7 +392,7 @@ var _ = Describe("Packet packer", func() {
return fs, 0
}),
)
_, err := packer.PackAppDataPacket()
_, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
})
@ -409,7 +409,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
expectAppendControlFrames()
expectAppendStreamFrames(ackhandler.Frame{Frame: f})
packet, err := packer.PackAppDataPacket()
packet, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
// cut off the tag that the mock sealer added
packet.buffer.Data = packet.buffer.Data[:packet.buffer.Len()-protocol.ByteCount(sealer.Overhead())]
@ -458,7 +458,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
expectAppendControlFrames()
expectAppendStreamFrames(ackhandler.Frame{Frame: f1}, ackhandler.Frame{Frame: f2}, ackhandler.Frame{Frame: f3})
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.frames).To(HaveLen(3))
@ -476,7 +476,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
expectAppendControlFrames()
expectAppendStreamFrames()
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.ack).ToNot(BeNil())
@ -492,7 +492,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
expectAppendControlFrames()
expectAppendStreamFrames()
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.frames).To(ContainElement(ackhandler.Frame{Frame: &wire.PingFrame{}}))
@ -503,7 +503,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
expectAppendControlFrames()
expectAppendStreamFrames()
p, err = packer.PackAppDataPacket()
p, err = packer.PackPacket()
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.ack).ToNot(BeNil())
@ -518,7 +518,7 @@ var _ = Describe("Packet packer", func() {
expectAppendControlFrames()
expectAppendStreamFrames()
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p).To(BeNil())
// now add some frame to send
@ -529,7 +529,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}}
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT).Return(ack)
p, err = packer.PackAppDataPacket()
p, err = packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.ack).To(Equal(ack))
Expect(p.frames).To(Equal([]ackhandler.Frame{{Frame: &wire.PingFrame{}}}))
@ -543,7 +543,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT)
expectAppendStreamFrames()
expectAppendControlFrames(ackhandler.Frame{Frame: &wire.MaxDataFrame{}})
p, err := packer.PackAppDataPacket()
p, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p).ToNot(BeNil())
Expect(p.frames).ToNot(ContainElement(&wire.PingFrame{}))
@ -561,7 +561,7 @@ var _ = Describe("Packet packer", func() {
return nil, 0
})
expectAppendStreamFrames()
_, err := packer.PackAppDataPacket()
_, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
// now reduce the maxPacketSize
packer.HandleTransportParameters(&handshake.TransportParameters{
@ -572,7 +572,7 @@ var _ = Describe("Packet packer", func() {
return nil, 0
})
expectAppendStreamFrames()
_, err = packer.PackAppDataPacket()
_, err = packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
})
@ -586,7 +586,7 @@ var _ = Describe("Packet packer", func() {
return nil, 0
})
expectAppendStreamFrames()
_, err := packer.PackAppDataPacket()
_, err := packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
// now try to increase the maxPacketSize
packer.HandleTransportParameters(&handshake.TransportParameters{
@ -597,7 +597,7 @@ var _ = Describe("Packet packer", func() {
return nil, 0
})
expectAppendStreamFrames()
_, err = packer.PackAppDataPacket()
_, err = packer.PackPacket()
Expect(err).ToNot(HaveOccurred())
})
})
@ -617,7 +617,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().GetInitialSealer().Return(getSealer(), nil)
sealingManager.EXPECT().GetHandshakeSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
checkLength(p.buffer.Data)
})
@ -638,7 +638,7 @@ var _ = Describe("Packet packer", func() {
Expect(f.Length(packer.version)).To(Equal(size))
return f
})
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
Expect(p.packets[0].frames).To(HaveLen(1))
@ -665,7 +665,7 @@ var _ = Describe("Packet packer", func() {
handshakeStream.EXPECT().PopCryptoFrame(gomock.Any()).DoAndReturn(func(size protocol.ByteCount) *wire.CryptoFrame {
return &wire.CryptoFrame{Offset: 0x1337, Data: []byte("handshake")}
})
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(2))
Expect(p.packets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
@ -697,7 +697,7 @@ var _ = Describe("Packet packer", func() {
Expect(f.Length(packer.version)).To(Equal(s))
return f
})
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
Expect(p.packets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
@ -716,7 +716,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
initialStream.EXPECT().HasData()
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
Expect(p.packets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
@ -734,7 +734,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionInitial).Return(protocol.PacketNumber(0x42))
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
Expect(p.packets[0].ack).To(Equal(ack))
@ -746,7 +746,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
initialStream.EXPECT().HasData()
ackFramer.EXPECT().GetAckFrame(protocol.EncryptionInitial)
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p).To(BeNil())
})
@ -762,7 +762,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(nil, handshake.ErrKeysNotYetAvailable)
pnManager.EXPECT().PeekPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
pnManager.EXPECT().PopPacketNumber(protocol.EncryptionHandshake).Return(protocol.PacketNumber(0x42))
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
Expect(p.packets[0].ack).To(Equal(ack))
@ -782,7 +782,7 @@ var _ = Describe("Packet packer", func() {
initialStream.EXPECT().HasData().Return(true).Times(2)
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
packer.perspective = protocol.PerspectiveClient
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.buffer.Len()).To(BeEquivalentTo(protocol.MinInitialPacketSize))
Expect(p.packets).To(HaveLen(1))
@ -807,7 +807,7 @@ var _ = Describe("Packet packer", func() {
initialStream.EXPECT().PopCryptoFrame(gomock.Any()).Return(f)
packer.version = protocol.VersionTLS
packer.perspective = protocol.PerspectiveClient
p, err := packer.PackPacket()
p, err := packer.PackCoalescedPacket()
Expect(err).ToNot(HaveOccurred())
Expect(p.packets).To(HaveLen(1))
Expect(p.packets[0].ack).To(Equal(ack))

View file

@ -1311,7 +1311,7 @@ func (s *session) sendPacket() (bool, error) {
if !s.handshakeConfirmed {
now := time.Now()
packet, err := s.packer.PackPacket()
packet, err := s.packer.PackCoalescedPacket()
if err != nil || packet == nil {
return false, err
}
@ -1326,7 +1326,7 @@ func (s *session) sendPacket() (bool, error) {
s.sendQueue.Send(packet.buffer)
return true, nil
}
packet, err := s.packer.PackAppDataPacket()
packet, err := s.packer.PackPacket()
if err != nil || packet == nil {
return false, err
}

View file

@ -887,7 +887,7 @@ var _ = Describe("Session", func() {
It("sends packets", func() {
sess.handshakeConfirmed = true
packer.EXPECT().PackAppDataPacket().Return(getPacket(1), nil)
packer.EXPECT().PackPacket().Return(getPacket(1), nil)
sess.receivedPacketHandler.ReceivedPacket(0x035e, protocol.Encryption1RTT, time.Now(), true)
mconn.EXPECT().Write(gomock.Any())
sent, err := sess.sendPacket()
@ -897,7 +897,7 @@ var _ = Describe("Session", func() {
It("doesn't send packets if there's nothing to send", func() {
sess.handshakeConfirmed = true
packer.EXPECT().PackAppDataPacket().Return(nil, nil)
packer.EXPECT().PackPacket().Return(nil, nil)
sess.receivedPacketHandler.ReceivedPacket(0x035e, protocol.Encryption1RTT, time.Now(), true)
sent, err := sess.sendPacket()
Expect(err).NotTo(HaveOccurred())
@ -918,7 +918,7 @@ var _ = Describe("Session", func() {
sess.handshakeConfirmed = true
fc := mocks.NewMockConnectionFlowController(mockCtrl)
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
packer.EXPECT().PackAppDataPacket().Return(getPacket(1), nil)
packer.EXPECT().PackPacket().Return(getPacket(1), nil)
sess.connFlowController = fc
mconn.EXPECT().Write(gomock.Any())
sent, err := sess.sendPacket()
@ -1022,8 +1022,8 @@ var _ = Describe("Session", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now()).Times(2)
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
sph.EXPECT().SendMode().Return(ackhandler.SendAny).Times(2) // allow 2 packets...
packer.EXPECT().PackAppDataPacket().Return(getPacket(10), nil)
packer.EXPECT().PackAppDataPacket().Return(getPacket(11), nil)
packer.EXPECT().PackPacket().Return(getPacket(10), nil)
packer.EXPECT().PackPacket().Return(getPacket(11), nil)
mconn.EXPECT().Write(gomock.Any()).Times(2)
go func() {
defer GinkgoRecover()
@ -1042,7 +1042,7 @@ var _ = Describe("Session", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now())
sph.EXPECT().SendMode().Return(ackhandler.SendAny)
sph.EXPECT().SendMode().Return(ackhandler.SendAck)
packer.EXPECT().PackAppDataPacket().Return(getPacket(100), nil)
packer.EXPECT().PackPacket().Return(getPacket(100), nil)
mconn.EXPECT().Write(gomock.Any())
go func() {
defer GinkgoRecover()
@ -1061,8 +1061,8 @@ var _ = Describe("Session", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
sph.EXPECT().ShouldSendNumPackets().Times(2).Return(1)
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
packer.EXPECT().PackAppDataPacket().Return(getPacket(100), nil)
packer.EXPECT().PackAppDataPacket().Return(getPacket(101), nil)
packer.EXPECT().PackPacket().Return(getPacket(100), nil)
packer.EXPECT().PackPacket().Return(getPacket(101), nil)
written := make(chan struct{}, 2)
mconn.EXPECT().Write(gomock.Any()).DoAndReturn(func(p []byte) (int, error) {
written <- struct{}{}
@ -1085,9 +1085,9 @@ var _ = Describe("Session", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now())
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
sph.EXPECT().SendMode().Return(ackhandler.SendAny).Times(3)
packer.EXPECT().PackAppDataPacket().Return(getPacket(1000), nil)
packer.EXPECT().PackAppDataPacket().Return(getPacket(1001), nil)
packer.EXPECT().PackAppDataPacket().Return(getPacket(1002), nil)
packer.EXPECT().PackPacket().Return(getPacket(1000), nil)
packer.EXPECT().PackPacket().Return(getPacket(1001), nil)
packer.EXPECT().PackPacket().Return(getPacket(1002), nil)
written := make(chan struct{}, 3)
mconn.EXPECT().Write(gomock.Any()).DoAndReturn(func(p []byte) (int, error) {
written <- struct{}{}
@ -1106,7 +1106,7 @@ var _ = Describe("Session", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now())
sph.EXPECT().ShouldSendNumPackets().Return(1)
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
packer.EXPECT().PackAppDataPacket()
packer.EXPECT().PackPacket()
// don't EXPECT any calls to mconn.Write()
go func() {
defer GinkgoRecover()
@ -1142,7 +1142,7 @@ var _ = Describe("Session", func() {
sph.EXPECT().ShouldSendNumPackets().AnyTimes().Return(1)
sph.EXPECT().SentPacket(gomock.Any())
sess.sentPacketHandler = sph
packer.EXPECT().PackAppDataPacket().Return(getPacket(1), nil)
packer.EXPECT().PackPacket().Return(getPacket(1), nil)
go func() {
defer GinkgoRecover()
@ -1159,7 +1159,7 @@ var _ = Describe("Session", func() {
})
It("sets the timer to the ack timer", func() {
packer.EXPECT().PackAppDataPacket().Return(getPacket(1234), nil)
packer.EXPECT().PackPacket().Return(getPacket(1234), nil)
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
sph.EXPECT().TimeUntilSend().Return(time.Now())
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
@ -1193,7 +1193,7 @@ var _ = Describe("Session", func() {
sess.sentPacketHandler = sph
buffer := getPacketBuffer()
buffer.Data = append(buffer.Data, []byte("foobar")...)
packer.EXPECT().PackPacket().Return(&coalescedPacket{
packer.EXPECT().PackCoalescedPacket().Return(&coalescedPacket{
buffer: buffer,
packets: []*packetContents{
{
@ -1218,7 +1218,7 @@ var _ = Describe("Session", func() {
},
},
}, nil)
packer.EXPECT().PackPacket().AnyTimes()
packer.EXPECT().PackCoalescedPacket().AnyTimes()
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
@ -1257,7 +1257,7 @@ var _ = Describe("Session", func() {
})
It("cancels the HandshakeComplete context and informs the SentPacketHandler when the handshake completes", func() {
packer.EXPECT().PackPacket().AnyTimes()
packer.EXPECT().PackCoalescedPacket().AnyTimes()
finishHandshake := make(chan struct{})
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
sess.sentPacketHandler = sph
@ -1294,7 +1294,7 @@ var _ = Describe("Session", func() {
It("sends a session ticket when the handshake completes", func() {
const size = protocol.MaxPostHandshakeCryptoFrameSize * 3 / 2
packer.EXPECT().PackPacket().AnyTimes()
packer.EXPECT().PackCoalescedPacket().AnyTimes()
finishHandshake := make(chan struct{})
sessionRunner.EXPECT().Retire(clientDestConnID)
go func() {
@ -1334,7 +1334,7 @@ var _ = Describe("Session", func() {
})
It("doesn't cancel the HandshakeComplete context when the handshake fails", func() {
packer.EXPECT().PackPacket().AnyTimes()
packer.EXPECT().PackCoalescedPacket().AnyTimes()
streamManager.EXPECT().CloseWithError(gomock.Any())
expectReplaceWithClosed()
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{buffer: getPacketBuffer()}, nil)
@ -1355,7 +1355,7 @@ var _ = Describe("Session", func() {
It("sends a HANDSHAKE_DONE frame when the handshake completes", func() {
done := make(chan struct{})
sessionRunner.EXPECT().Retire(clientDestConnID)
packer.EXPECT().PackPacket().DoAndReturn(func() (*packedPacket, error) {
packer.EXPECT().PackCoalescedPacket().DoAndReturn(func() (*packedPacket, error) {
frames, _ := sess.framer.AppendControlFrames(nil, protocol.MaxByteCount)
Expect(frames).ToNot(BeEmpty())
Expect(frames[0].Frame).To(BeEquivalentTo(&wire.HandshakeDoneFrame{}))
@ -1367,7 +1367,7 @@ var _ = Describe("Session", func() {
buffer: getPacketBuffer(),
}, nil
})
packer.EXPECT().PackPacket().AnyTimes()
packer.EXPECT().PackCoalescedPacket().AnyTimes()
go func() {
defer GinkgoRecover()
cryptoSetup.EXPECT().RunHandshake()
@ -1441,7 +1441,7 @@ var _ = Describe("Session", func() {
}
streamManager.EXPECT().UpdateLimits(params)
packer.EXPECT().HandleTransportParameters(params)
packer.EXPECT().PackPacket().MaxTimes(3)
packer.EXPECT().PackCoalescedPacket().MaxTimes(3)
Expect(sess.earlySessionReady()).ToNot(BeClosed())
sessionRunner.EXPECT().GetStatelessResetToken(gomock.Any()).Times(2)
sessionRunner.EXPECT().Add(gomock.Any(), sess).Times(2)
@ -1497,7 +1497,7 @@ var _ = Describe("Session", func() {
setRemoteIdleTimeout(5 * time.Second)
sess.lastPacketReceivedTime = time.Now().Add(-5 * time.Second / 2)
sent := make(chan struct{})
packer.EXPECT().PackPacket().Do(func() (*packedPacket, error) {
packer.EXPECT().PackCoalescedPacket().Do(func() (*packedPacket, error) {
close(sent)
return nil, nil
})
@ -1510,7 +1510,7 @@ var _ = Describe("Session", func() {
setRemoteIdleTimeout(time.Hour)
sess.lastPacketReceivedTime = time.Now().Add(-protocol.MaxKeepAliveInterval).Add(-time.Millisecond)
sent := make(chan struct{})
packer.EXPECT().PackPacket().Do(func() (*packedPacket, error) {
packer.EXPECT().PackCoalescedPacket().Do(func() (*packedPacket, error) {
close(sent)
return nil, nil
})
@ -1606,7 +1606,7 @@ var _ = Describe("Session", func() {
})
It("closes the session due to the idle timeout after handshake", func() {
packer.EXPECT().PackPacket().AnyTimes()
packer.EXPECT().PackCoalescedPacket().AnyTimes()
gomock.InOrder(
sessionRunner.EXPECT().Retire(clientDestConnID),
sessionRunner.EXPECT().Remove(gomock.Any()),
@ -1965,7 +1965,7 @@ var _ = Describe("Client Session", func() {
},
}
packer.EXPECT().HandleTransportParameters(gomock.Any())
packer.EXPECT().PackPacket().MaxTimes(1)
packer.EXPECT().PackCoalescedPacket().MaxTimes(1)
sess.processTransportParameters(params)
cf, _ := sess.framer.AppendControlFrames(nil, protocol.MaxByteCount)
Expect(cf).To(HaveLen(1))