diff --git a/ackhandler/ackhandler_suite_test.go b/ackhandler/ackhandler_suite_test.go index 53108c19..9e7e0777 100644 --- a/ackhandler/ackhandler_suite_test.go +++ b/ackhandler/ackhandler_suite_test.go @@ -1,6 +1,7 @@ package ackhandler import ( + "github.com/golang/mock/gomock" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" @@ -11,3 +12,13 @@ func TestCrypto(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "AckHandler Suite") } + +var mockCtrl *gomock.Controller + +var _ = BeforeEach(func() { + mockCtrl = gomock.NewController(GinkgoT()) +}) + +var _ = AfterEach(func() { + mockCtrl.Finish() +}) diff --git a/ackhandler/sent_packet_handler.go b/ackhandler/sent_packet_handler.go index b30a78f7..102e33cd 100644 --- a/ackhandler/sent_packet_handler.go +++ b/ackhandler/sent_packet_handler.go @@ -365,12 +365,11 @@ func (h *sentPacketHandler) GetStopWaitingFrame(force bool) *wire.StopWaitingFra } func (h *sentPacketHandler) SendingAllowed() bool { - congestionLimited := h.bytesInFlight > h.congestion.GetCongestionWindow() + cwnd := h.congestion.GetCongestionWindow() + congestionLimited := h.bytesInFlight > cwnd maxTrackedLimited := protocol.PacketNumber(len(h.retransmissionQueue)+h.packetHistory.Len()) >= protocol.MaxTrackedSentPackets if congestionLimited { - utils.Debugf("Congestion limited: bytes in flight %d, window %d", - h.bytesInFlight, - h.congestion.GetCongestionWindow()) + utils.Debugf("Congestion limited: bytes in flight %d, window %d", h.bytesInFlight, cwnd) } // Workaround for #555: // Always allow sending of retransmissions. This should probably be limited diff --git a/ackhandler/sent_packet_handler_test.go b/ackhandler/sent_packet_handler_test.go index f44b0285..e663a2b9 100644 --- a/ackhandler/sent_packet_handler_test.go +++ b/ackhandler/sent_packet_handler_test.go @@ -3,60 +3,15 @@ package ackhandler import ( "time" + "github.com/golang/mock/gomock" "github.com/lucas-clemente/quic-go/congestion" + "github.com/lucas-clemente/quic-go/internal/mocks" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) -type mockCongestion struct { - argsOnPacketSent []interface{} - maybeExitSlowStart bool - onRetransmissionTimeout bool - getCongestionWindow bool - packetsAcked [][]interface{} - packetsLost [][]interface{} -} - -func (m *mockCongestion) TimeUntilSend(now time.Time, bytesInFlight protocol.ByteCount) time.Duration { - panic("not implemented") -} - -func (m *mockCongestion) OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool) bool { - m.argsOnPacketSent = []interface{}{sentTime, bytesInFlight, packetNumber, bytes, isRetransmittable} - return false -} - -func (m *mockCongestion) GetCongestionWindow() protocol.ByteCount { - m.getCongestionWindow = true - return protocol.DefaultTCPMSS -} - -func (m *mockCongestion) MaybeExitSlowStart() { - m.maybeExitSlowStart = true -} - -func (m *mockCongestion) OnRetransmissionTimeout(packetsRetransmitted bool) { - m.onRetransmissionTimeout = true -} - -func (m *mockCongestion) RetransmissionDelay() time.Duration { - return defaultRTOTimeout -} - -func (m *mockCongestion) SetNumEmulatedConnections(n int) { panic("not implemented") } -func (m *mockCongestion) OnConnectionMigration() { panic("not implemented") } -func (m *mockCongestion) SetSlowStartLargeReduction(enabled bool) { panic("not implemented") } - -func (m *mockCongestion) OnPacketAcked(n protocol.PacketNumber, l protocol.ByteCount, bif protocol.ByteCount) { - m.packetsAcked = append(m.packetsAcked, []interface{}{n, l, bif}) -} - -func (m *mockCongestion) OnPacketLost(n protocol.PacketNumber, l protocol.ByteCount, bif protocol.ByteCount) { - m.packetsLost = append(m.packetsLost, []interface{}{n, l, bif}) -} - func retransmittablePacket(num protocol.PacketNumber) *Packet { return &Packet{ PacketNumber: num, @@ -708,15 +663,23 @@ var _ = Describe("SentPacketHandler", func() { Context("congestion", func() { var ( - cong *mockCongestion + cong *mocks.MockSendAlgorithm ) BeforeEach(func() { - cong = &mockCongestion{} + cong = mocks.NewMockSendAlgorithm(mockCtrl) + cong.EXPECT().RetransmissionDelay().AnyTimes() handler.congestion = cong }) It("should call OnSent", func() { + cong.EXPECT().OnPacketSent( + gomock.Any(), + protocol.ByteCount(42), + protocol.PacketNumber(1), + protocol.ByteCount(42), + true, + ) p := &Packet{ PacketNumber: 1, Length: 42, @@ -724,62 +687,60 @@ var _ = Describe("SentPacketHandler", func() { } err := handler.SentPacket(p) Expect(err).NotTo(HaveOccurred()) - Expect(cong.argsOnPacketSent[1]).To(Equal(protocol.ByteCount(42))) - Expect(cong.argsOnPacketSent[2]).To(Equal(protocol.PacketNumber(1))) - Expect(cong.argsOnPacketSent[3]).To(Equal(protocol.ByteCount(42))) - Expect(cong.argsOnPacketSent[4]).To(BeTrue()) }) It("should call MaybeExitSlowStart and OnPacketAcked", func() { + cong.EXPECT().OnPacketSent(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2) + cong.EXPECT().MaybeExitSlowStart() + cong.EXPECT().OnPacketAcked( + protocol.PacketNumber(1), + protocol.ByteCount(1), + protocol.ByteCount(1), + ) handler.SentPacket(retransmittablePacket(1)) handler.SentPacket(retransmittablePacket(2)) err := handler.ReceivedAck(&wire.AckFrame{LargestAcked: 1, LowestAcked: 1}, 1, protocol.EncryptionForwardSecure, time.Now()) Expect(err).NotTo(HaveOccurred()) - Expect(cong.maybeExitSlowStart).To(BeTrue()) - Expect(cong.packetsAcked).To(BeEquivalentTo([][]interface{}{ - {protocol.PacketNumber(1), protocol.ByteCount(1), protocol.ByteCount(1)}, - })) - Expect(cong.packetsLost).To(BeEmpty()) }) It("should call MaybeExitSlowStart and OnPacketLost", func() { + cong.EXPECT().OnPacketSent(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(3) + cong.EXPECT().OnRetransmissionTimeout(true).Times(2) + cong.EXPECT().OnPacketLost( + protocol.PacketNumber(1), + protocol.ByteCount(1), + protocol.ByteCount(2), + ) + cong.EXPECT().OnPacketLost( + protocol.PacketNumber(2), + protocol.ByteCount(1), + protocol.ByteCount(1), + ) handler.SentPacket(retransmittablePacket(1)) handler.SentPacket(retransmittablePacket(2)) handler.SentPacket(retransmittablePacket(3)) handler.OnAlarm() // RTO, meaning 2 lost packets - Expect(cong.maybeExitSlowStart).To(BeFalse()) - Expect(cong.onRetransmissionTimeout).To(BeTrue()) - Expect(cong.packetsAcked).To(BeEmpty()) - Expect(cong.packetsLost).To(BeEquivalentTo([][]interface{}{ - {protocol.PacketNumber(1), protocol.ByteCount(1), protocol.ByteCount(2)}, - {protocol.PacketNumber(2), protocol.ByteCount(1), protocol.ByteCount(1)}, - })) }) It("allows or denies sending based on congestion", func() { + Expect(handler.retransmissionQueue).To(BeEmpty()) + handler.bytesInFlight = 100 + cong.EXPECT().GetCongestionWindow().Return(protocol.MaxByteCount) Expect(handler.SendingAllowed()).To(BeTrue()) - err := handler.SentPacket(&Packet{ - PacketNumber: 1, - Frames: []wire.Frame{&wire.PingFrame{}}, - Length: protocol.DefaultTCPMSS + 1, - }) - Expect(err).NotTo(HaveOccurred()) + cong.EXPECT().GetCongestionWindow().Return(protocol.ByteCount(0)) Expect(handler.SendingAllowed()).To(BeFalse()) }) It("allows or denies sending based on the number of tracked packets", func() { + cong.EXPECT().GetCongestionWindow().Return(protocol.MaxByteCount).AnyTimes() Expect(handler.SendingAllowed()).To(BeTrue()) handler.retransmissionQueue = make([]*Packet, protocol.MaxTrackedSentPackets) Expect(handler.SendingAllowed()).To(BeFalse()) }) It("allows sending if there are retransmisisons outstanding", func() { - err := handler.SentPacket(&Packet{ - PacketNumber: 1, - Frames: []wire.Frame{&wire.PingFrame{}}, - Length: protocol.DefaultTCPMSS + 1, - }) - Expect(err).NotTo(HaveOccurred()) + handler.bytesInFlight = 100 + cong.EXPECT().GetCongestionWindow().Return(protocol.ByteCount(0)).AnyTimes() Expect(handler.SendingAllowed()).To(BeFalse()) handler.retransmissionQueue = []*Packet{nil} Expect(handler.SendingAllowed()).To(BeTrue()) diff --git a/internal/mocks/received_packet_handler.go b/internal/mocks/ackhandler/received_packet_handler.go similarity index 97% rename from internal/mocks/received_packet_handler.go rename to internal/mocks/ackhandler/received_packet_handler.go index a90aeb6b..03e0ce73 100644 --- a/internal/mocks/received_packet_handler.go +++ b/internal/mocks/ackhandler/received_packet_handler.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/lucas-clemente/quic-go/ackhandler (interfaces: ReceivedPacketHandler) -// Package mocks is a generated GoMock package. -package mocks +// Package mockackhandler is a generated GoMock package. +package mockackhandler import ( reflect "reflect" diff --git a/internal/mocks/sent_packet_handler.go b/internal/mocks/ackhandler/sent_packet_handler.go similarity index 98% rename from internal/mocks/sent_packet_handler.go rename to internal/mocks/ackhandler/sent_packet_handler.go index a9f7a4b0..47a77e8f 100644 --- a/internal/mocks/sent_packet_handler.go +++ b/internal/mocks/ackhandler/sent_packet_handler.go @@ -1,8 +1,8 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/lucas-clemente/quic-go/ackhandler (interfaces: SentPacketHandler) -// Package mocks is a generated GoMock package. -package mocks +// Package mockackhandler is a generated GoMock package. +package mockackhandler import ( reflect "reflect" diff --git a/internal/mocks/congestion.go b/internal/mocks/congestion.go new file mode 100644 index 00000000..b6c085df --- /dev/null +++ b/internal/mocks/congestion.go @@ -0,0 +1,154 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/lucas-clemente/quic-go/congestion (interfaces: SendAlgorithm) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + reflect "reflect" + time "time" + + gomock "github.com/golang/mock/gomock" + protocol "github.com/lucas-clemente/quic-go/internal/protocol" +) + +// MockSendAlgorithm is a mock of SendAlgorithm interface +type MockSendAlgorithm struct { + ctrl *gomock.Controller + recorder *MockSendAlgorithmMockRecorder +} + +// MockSendAlgorithmMockRecorder is the mock recorder for MockSendAlgorithm +type MockSendAlgorithmMockRecorder struct { + mock *MockSendAlgorithm +} + +// NewMockSendAlgorithm creates a new mock instance +func NewMockSendAlgorithm(ctrl *gomock.Controller) *MockSendAlgorithm { + mock := &MockSendAlgorithm{ctrl: ctrl} + mock.recorder = &MockSendAlgorithmMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockSendAlgorithm) EXPECT() *MockSendAlgorithmMockRecorder { + return m.recorder +} + +// GetCongestionWindow mocks base method +func (m *MockSendAlgorithm) GetCongestionWindow() protocol.ByteCount { + ret := m.ctrl.Call(m, "GetCongestionWindow") + ret0, _ := ret[0].(protocol.ByteCount) + return ret0 +} + +// GetCongestionWindow indicates an expected call of GetCongestionWindow +func (mr *MockSendAlgorithmMockRecorder) GetCongestionWindow() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCongestionWindow", reflect.TypeOf((*MockSendAlgorithm)(nil).GetCongestionWindow)) +} + +// MaybeExitSlowStart mocks base method +func (m *MockSendAlgorithm) MaybeExitSlowStart() { + m.ctrl.Call(m, "MaybeExitSlowStart") +} + +// MaybeExitSlowStart indicates an expected call of MaybeExitSlowStart +func (mr *MockSendAlgorithmMockRecorder) MaybeExitSlowStart() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybeExitSlowStart", reflect.TypeOf((*MockSendAlgorithm)(nil).MaybeExitSlowStart)) +} + +// OnConnectionMigration mocks base method +func (m *MockSendAlgorithm) OnConnectionMigration() { + m.ctrl.Call(m, "OnConnectionMigration") +} + +// OnConnectionMigration indicates an expected call of OnConnectionMigration +func (mr *MockSendAlgorithmMockRecorder) OnConnectionMigration() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnConnectionMigration", reflect.TypeOf((*MockSendAlgorithm)(nil).OnConnectionMigration)) +} + +// OnPacketAcked mocks base method +func (m *MockSendAlgorithm) OnPacketAcked(arg0 protocol.PacketNumber, arg1, arg2 protocol.ByteCount) { + m.ctrl.Call(m, "OnPacketAcked", arg0, arg1, arg2) +} + +// OnPacketAcked indicates an expected call of OnPacketAcked +func (mr *MockSendAlgorithmMockRecorder) OnPacketAcked(arg0, arg1, arg2 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnPacketAcked", reflect.TypeOf((*MockSendAlgorithm)(nil).OnPacketAcked), arg0, arg1, arg2) +} + +// OnPacketLost mocks base method +func (m *MockSendAlgorithm) OnPacketLost(arg0 protocol.PacketNumber, arg1, arg2 protocol.ByteCount) { + m.ctrl.Call(m, "OnPacketLost", arg0, arg1, arg2) +} + +// OnPacketLost indicates an expected call of OnPacketLost +func (mr *MockSendAlgorithmMockRecorder) OnPacketLost(arg0, arg1, arg2 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnPacketLost", reflect.TypeOf((*MockSendAlgorithm)(nil).OnPacketLost), arg0, arg1, arg2) +} + +// OnPacketSent mocks base method +func (m *MockSendAlgorithm) OnPacketSent(arg0 time.Time, arg1 protocol.ByteCount, arg2 protocol.PacketNumber, arg3 protocol.ByteCount, arg4 bool) bool { + ret := m.ctrl.Call(m, "OnPacketSent", arg0, arg1, arg2, arg3, arg4) + ret0, _ := ret[0].(bool) + return ret0 +} + +// OnPacketSent indicates an expected call of OnPacketSent +func (mr *MockSendAlgorithmMockRecorder) OnPacketSent(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnPacketSent", reflect.TypeOf((*MockSendAlgorithm)(nil).OnPacketSent), arg0, arg1, arg2, arg3, arg4) +} + +// OnRetransmissionTimeout mocks base method +func (m *MockSendAlgorithm) OnRetransmissionTimeout(arg0 bool) { + m.ctrl.Call(m, "OnRetransmissionTimeout", arg0) +} + +// OnRetransmissionTimeout indicates an expected call of OnRetransmissionTimeout +func (mr *MockSendAlgorithmMockRecorder) OnRetransmissionTimeout(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnRetransmissionTimeout", reflect.TypeOf((*MockSendAlgorithm)(nil).OnRetransmissionTimeout), arg0) +} + +// RetransmissionDelay mocks base method +func (m *MockSendAlgorithm) RetransmissionDelay() time.Duration { + ret := m.ctrl.Call(m, "RetransmissionDelay") + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// RetransmissionDelay indicates an expected call of RetransmissionDelay +func (mr *MockSendAlgorithmMockRecorder) RetransmissionDelay() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RetransmissionDelay", reflect.TypeOf((*MockSendAlgorithm)(nil).RetransmissionDelay)) +} + +// SetNumEmulatedConnections mocks base method +func (m *MockSendAlgorithm) SetNumEmulatedConnections(arg0 int) { + m.ctrl.Call(m, "SetNumEmulatedConnections", arg0) +} + +// SetNumEmulatedConnections indicates an expected call of SetNumEmulatedConnections +func (mr *MockSendAlgorithmMockRecorder) SetNumEmulatedConnections(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetNumEmulatedConnections", reflect.TypeOf((*MockSendAlgorithm)(nil).SetNumEmulatedConnections), arg0) +} + +// SetSlowStartLargeReduction mocks base method +func (m *MockSendAlgorithm) SetSlowStartLargeReduction(arg0 bool) { + m.ctrl.Call(m, "SetSlowStartLargeReduction", arg0) +} + +// SetSlowStartLargeReduction indicates an expected call of SetSlowStartLargeReduction +func (mr *MockSendAlgorithmMockRecorder) SetSlowStartLargeReduction(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSlowStartLargeReduction", reflect.TypeOf((*MockSendAlgorithm)(nil).SetSlowStartLargeReduction), arg0) +} + +// TimeUntilSend mocks base method +func (m *MockSendAlgorithm) TimeUntilSend(arg0 time.Time, arg1 protocol.ByteCount) time.Duration { + ret := m.ctrl.Call(m, "TimeUntilSend", arg0, arg1) + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// TimeUntilSend indicates an expected call of TimeUntilSend +func (mr *MockSendAlgorithmMockRecorder) TimeUntilSend(arg0, arg1 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TimeUntilSend", reflect.TypeOf((*MockSendAlgorithm)(nil).TimeUntilSend), arg0, arg1) +} diff --git a/internal/mocks/gen.go b/internal/mocks/gen.go index ff93e9c9..a9f5afe5 100644 --- a/internal/mocks/gen.go +++ b/internal/mocks/gen.go @@ -3,8 +3,9 @@ package mocks //go:generate sh -c "./mockgen_internal.sh mockhandshake handshake/mint_tls.go github.com/lucas-clemente/quic-go/internal/handshake MintTLS" //go:generate sh -c "./mockgen_internal.sh mocks tls_extension_handler.go github.com/lucas-clemente/quic-go/internal/handshake TLSExtensionHandler" //go:generate sh -c "./mockgen_internal.sh mocks stream_flow_controller.go github.com/lucas-clemente/quic-go/internal/flowcontrol StreamFlowController" -//go:generate sh -c "./mockgen_internal.sh mocks sent_packet_handler.go github.com/lucas-clemente/quic-go/ackhandler SentPacketHandler" -//go:generate sh -c "./mockgen_internal.sh mocks received_packet_handler.go github.com/lucas-clemente/quic-go/ackhandler ReceivedPacketHandler" +//go:generate sh -c "./mockgen_internal.sh mockackhandler ackhandler/sent_packet_handler.go github.com/lucas-clemente/quic-go/ackhandler SentPacketHandler" +//go:generate sh -c "./mockgen_internal.sh mockackhandler ackhandler/received_packet_handler.go github.com/lucas-clemente/quic-go/ackhandler ReceivedPacketHandler" +//go:generate sh -c "./mockgen_internal.sh mocks congestion.go github.com/lucas-clemente/quic-go/congestion SendAlgorithm" //go:generate sh -c "./mockgen_internal.sh mocks connection_flow_controller.go github.com/lucas-clemente/quic-go/internal/flowcontrol ConnectionFlowController" //go:generate sh -c "./mockgen_internal.sh mockcrypto crypto/aead.go github.com/lucas-clemente/quic-go/internal/crypto AEAD" //go:generate sh -c "goimports -w ." diff --git a/session_test.go b/session_test.go index da4b1b55..39115c01 100644 --- a/session_test.go +++ b/session_test.go @@ -19,6 +19,7 @@ import ( "github.com/lucas-clemente/quic-go/internal/crypto" "github.com/lucas-clemente/quic-go/internal/handshake" "github.com/lucas-clemente/quic-go/internal/mocks" + "github.com/lucas-clemente/quic-go/internal/mocks/ackhandler" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/testdata" "github.com/lucas-clemente/quic-go/internal/wire" @@ -274,7 +275,7 @@ var _ = Describe("Session", func() { Context("handling ACK frames", func() { It("informs the SentPacketHandler about ACKs", func() { f := &wire.AckFrame{LargestAcked: 3, LowestAcked: 2} - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().ReceivedAck(f, protocol.PacketNumber(42), protocol.EncryptionSecure, gomock.Any()) sph.EXPECT().GetLowestPacketNotConfirmedAcked() sess.sentPacketHandler = sph @@ -284,11 +285,11 @@ var _ = Describe("Session", func() { }) It("tells the ReceivedPacketHandler to ignore low ranges", func() { - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().ReceivedAck(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) sph.EXPECT().GetLowestPacketNotConfirmedAcked().Return(protocol.PacketNumber(0x42)) sess.sentPacketHandler = sph - rph := mocks.NewMockReceivedPacketHandler(mockCtrl) + rph := mockackhandler.NewMockReceivedPacketHandler(mockCtrl) rph.EXPECT().IgnoreBelow(protocol.PacketNumber(0x42)) sess.receivedPacketHandler = rph err := sess.handleAckFrame(&wire.AckFrame{LargestAcked: 3, LowestAcked: 2}, protocol.EncryptionUnencrypted) @@ -746,7 +747,7 @@ var _ = Describe("Session", func() { It("sends ACK frames when congestion limited", func() { swf := &wire.StopWaitingFrame{LeastUnacked: 10} - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(false) sph.EXPECT().GetStopWaitingFrame(false).Return(swf) @@ -765,7 +766,7 @@ var _ = Describe("Session", func() { It("doesn't include a STOP_WAITING for an ACK-only packet for IETF QUIC", func() { sess.version = versionIETFFrames - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(false) sph.EXPECT().SentPacket(gomock.Any()).Do(func(p *ackhandler.Packet) { @@ -782,7 +783,7 @@ var _ = Describe("Session", func() { It("sends a retransmittable packet when required by the SentPacketHandler", func() { sess.packer.QueueControlFrame(&wire.AckFrame{LargestAcked: 1000}) - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(true) sph.EXPECT().SendingAllowed().Return(false) @@ -800,7 +801,7 @@ var _ = Describe("Session", func() { fc.EXPECT().GetWindowUpdate().Return(protocol.ByteCount(0x1337)) fc.EXPECT().IsNewlyBlocked() sess.connFlowController = fc - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(true) sph.EXPECT().SendingAllowed() @@ -821,7 +822,7 @@ var _ = Describe("Session", func() { StreamID: 2, ByteOffset: 20, }) - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(true) sph.EXPECT().SendingAllowed() @@ -840,7 +841,7 @@ var _ = Describe("Session", func() { fc.EXPECT().GetWindowUpdate() fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337)) sess.connFlowController = fc - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(true) sph.EXPECT().SendingAllowed() @@ -869,7 +870,7 @@ var _ = Describe("Session", func() { Data: []byte("foobar"), } var sentPacket *ackhandler.Packet - sph := mocks.NewMockSentPacketHandler(mockCtrl) + sph := mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().GetStopWaitingFrame(gomock.Any()) sph.EXPECT().SendingAllowed().Return(true) @@ -897,12 +898,12 @@ var _ = Describe("Session", func() { }) Context("retransmissions", func() { - var sph *mocks.MockSentPacketHandler + var sph *mockackhandler.MockSentPacketHandler BeforeEach(func() { // a STOP_WAITING frame is added, so make sure the packet number of the new package is higher than the packet number of the retransmitted packet sess.packer.packetNumberGenerator.next = 0x1337 + 10 sess.packer.hasSentPacket = true // make sure this is not the first packet the packer sends - sph = mocks.NewMockSentPacketHandler(mockCtrl) + sph = mockackhandler.NewMockSentPacketHandler(mockCtrl) sph.EXPECT().GetLeastUnacked().AnyTimes() sph.EXPECT().SendingAllowed().Return(true) sph.EXPECT().ShouldSendRetransmittablePacket() @@ -1096,7 +1097,7 @@ var _ = Describe("Session", func() { }) It("sets the timer to the ack timer", func() { - rph := mocks.NewMockReceivedPacketHandler(mockCtrl) + rph := mockackhandler.NewMockReceivedPacketHandler(mockCtrl) rph.EXPECT().GetAckFrame().Return(&wire.AckFrame{LargestAcked: 0x1337}) rph.EXPECT().GetAlarmTimeout().Return(time.Now().Add(10 * time.Millisecond)).MinTimes(1) sess.receivedPacketHandler = rph