]> git.feebdaed.xyz Git - 0xmirror/quic-go.git/commitdiff
remove connection flow controller mock (#5213)
authorMarten Seemann <martenseemann@gmail.com>
Mon, 9 Jun 2025 07:26:23 +0000 (15:26 +0800)
committerGitHub <noreply@github.com>
Mon, 9 Jun 2025 07:26:23 +0000 (09:26 +0200)
No functional change expected.

connection_test.go
internal/mocks/connection_flow_controller.go [deleted file]
internal/mocks/mockgen.go

index 2812e26e308921142a4711a8379f3845f754175c..063ec492f7e4eaac812dd2fc1e66bad327350df0 100644 (file)
@@ -13,6 +13,7 @@ import (
        "time"
 
        "github.com/quic-go/quic-go/internal/ackhandler"
+       "github.com/quic-go/quic-go/internal/flowcontrol"
        "github.com/quic-go/quic-go/internal/handshake"
        "github.com/quic-go/quic-go/internal/mocks"
        mockackhandler "github.com/quic-go/quic-go/internal/mocks/ackhandler"
@@ -38,7 +39,7 @@ func connectionOptStreamManager(sm *MockStreamManager) testConnectionOpt {
        return func(conn *connection) { conn.streamsMap = sm }
 }
 
-func connectionOptConnFlowController(cfc *mocks.MockConnectionFlowController) testConnectionOpt {
+func connectionOptConnFlowController(cfc flowcontrol.ConnectionFlowController) testConnectionOpt {
        return func(conn *connection) { conn.connFlowController = cfc }
 }
 
@@ -350,14 +351,15 @@ func TestConnectionHandleStreamNumFrames(t *testing.T) {
 
 func TestConnectionHandleConnectionFlowControlFrames(t *testing.T) {
        mockCtrl := gomock.NewController(t)
-       connFC := mocks.NewMockConnectionFlowController(mockCtrl)
+       connFC := flowcontrol.NewConnectionFlowController(0, 0, nil, &utils.RTTStats{}, utils.DefaultLogger)
+       require.Zero(t, connFC.SendWindowSize())
        tc := newServerTestConnection(t, mockCtrl, nil, false, connectionOptConnFlowController(connFC))
        now := time.Now()
        connID := protocol.ConnectionID{}
        // MAX_DATA frame
-       connFC.EXPECT().UpdateSendWindow(protocol.ByteCount(1337))
        _, err := tc.conn.handleFrame(&wire.MaxDataFrame{MaximumData: 1337}, protocol.Encryption1RTT, connID, now)
        require.NoError(t, err)
+       require.Equal(t, protocol.ByteCount(1337), connFC.SendWindowSize())
        // DATA_BLOCKED frame
        _, err = tc.conn.handleFrame(&wire.DataBlockedFrame{MaximumData: 1337}, protocol.Encryption1RTT, connID, now)
        require.NoError(t, err)
@@ -1048,29 +1050,32 @@ func TestConnectionHandshakeIdleTimeout(t *testing.T) {
 func TestConnectionTransportParameters(t *testing.T) {
        mockCtrl := gomock.NewController(t)
        tr, tracer := mocklogging.NewMockConnectionTracer(mockCtrl)
-       streamManager := NewMockStreamManager(mockCtrl)
-       connFC := mocks.NewMockConnectionFlowController(mockCtrl)
+       connFC := flowcontrol.NewConnectionFlowController(0, 0, nil, &utils.RTTStats{}, utils.DefaultLogger)
+       require.Zero(t, connFC.SendWindowSize())
        tc := newServerTestConnection(t,
                mockCtrl,
                nil,
                false,
                connectionOptTracer(tr),
-               connectionOptStreamManager(streamManager),
                connectionOptConnFlowController(connFC),
        )
+       _, err := tc.conn.OpenStream()
+       require.ErrorIs(t, err, &StreamLimitReachedError{})
        tracer.EXPECT().ReceivedTransportParameters(gomock.Any())
        params := &wire.TransportParameters{
                MaxIdleTimeout:                90 * time.Second,
                InitialMaxStreamDataBidiLocal: 0x5000,
-               InitialMaxData:                0x5000,
+               InitialMaxData:                1337,
                ActiveConnectionIDLimit:       3,
                // marshaling always sets it to this value
                MaxUDPPayloadSize:               protocol.MaxPacketBufferSize,
                OriginalDestinationConnectionID: tc.destConnID,
+               MaxBidiStreamNum:                1,
        }
-       streamManager.EXPECT().UpdateLimits(params)
-       connFC.EXPECT().UpdateSendWindow(params.InitialMaxData)
        require.NoError(t, tc.conn.handleTransportParameters(params))
+       require.Equal(t, protocol.ByteCount(1337), connFC.SendWindowSize())
+       _, err = tc.conn.OpenStream()
+       require.NoError(t, err)
 }
 
 func TestConnectionTransportParameterValidationFailureServer(t *testing.T) {
diff --git a/internal/mocks/connection_flow_controller.go b/internal/mocks/connection_flow_controller.go
deleted file mode 100644 (file)
index 19a71d1..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-// Code generated by MockGen. DO NOT EDIT.
-// Source: github.com/quic-go/quic-go/internal/flowcontrol (interfaces: ConnectionFlowController)
-//
-// Generated by this command:
-//
-//     mockgen -typed -build_flags=-tags=gomock -package mocks -destination connection_flow_controller.go github.com/quic-go/quic-go/internal/flowcontrol ConnectionFlowController
-//
-
-// Package mocks is a generated GoMock package.
-package mocks
-
-import (
-       reflect "reflect"
-       time "time"
-
-       protocol "github.com/quic-go/quic-go/internal/protocol"
-       gomock "go.uber.org/mock/gomock"
-)
-
-// MockConnectionFlowController is a mock of ConnectionFlowController interface.
-type MockConnectionFlowController struct {
-       ctrl     *gomock.Controller
-       recorder *MockConnectionFlowControllerMockRecorder
-       isgomock struct{}
-}
-
-// MockConnectionFlowControllerMockRecorder is the mock recorder for MockConnectionFlowController.
-type MockConnectionFlowControllerMockRecorder struct {
-       mock *MockConnectionFlowController
-}
-
-// NewMockConnectionFlowController creates a new mock instance.
-func NewMockConnectionFlowController(ctrl *gomock.Controller) *MockConnectionFlowController {
-       mock := &MockConnectionFlowController{ctrl: ctrl}
-       mock.recorder = &MockConnectionFlowControllerMockRecorder{mock}
-       return mock
-}
-
-// EXPECT returns an object that allows the caller to indicate expected use.
-func (m *MockConnectionFlowController) EXPECT() *MockConnectionFlowControllerMockRecorder {
-       return m.recorder
-}
-
-// AddBytesRead mocks base method.
-func (m *MockConnectionFlowController) AddBytesRead(arg0 protocol.ByteCount) bool {
-       m.ctrl.T.Helper()
-       ret := m.ctrl.Call(m, "AddBytesRead", arg0)
-       ret0, _ := ret[0].(bool)
-       return ret0
-}
-
-// AddBytesRead indicates an expected call of AddBytesRead.
-func (mr *MockConnectionFlowControllerMockRecorder) AddBytesRead(arg0 any) *MockConnectionFlowControllerAddBytesReadCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBytesRead", reflect.TypeOf((*MockConnectionFlowController)(nil).AddBytesRead), arg0)
-       return &MockConnectionFlowControllerAddBytesReadCall{Call: call}
-}
-
-// MockConnectionFlowControllerAddBytesReadCall wrap *gomock.Call
-type MockConnectionFlowControllerAddBytesReadCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerAddBytesReadCall) Return(hasWindowUpdate bool) *MockConnectionFlowControllerAddBytesReadCall {
-       c.Call = c.Call.Return(hasWindowUpdate)
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerAddBytesReadCall) Do(f func(protocol.ByteCount) bool) *MockConnectionFlowControllerAddBytesReadCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerAddBytesReadCall) DoAndReturn(f func(protocol.ByteCount) bool) *MockConnectionFlowControllerAddBytesReadCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
-
-// AddBytesSent mocks base method.
-func (m *MockConnectionFlowController) AddBytesSent(arg0 protocol.ByteCount) {
-       m.ctrl.T.Helper()
-       m.ctrl.Call(m, "AddBytesSent", arg0)
-}
-
-// AddBytesSent indicates an expected call of AddBytesSent.
-func (mr *MockConnectionFlowControllerMockRecorder) AddBytesSent(arg0 any) *MockConnectionFlowControllerAddBytesSentCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddBytesSent", reflect.TypeOf((*MockConnectionFlowController)(nil).AddBytesSent), arg0)
-       return &MockConnectionFlowControllerAddBytesSentCall{Call: call}
-}
-
-// MockConnectionFlowControllerAddBytesSentCall wrap *gomock.Call
-type MockConnectionFlowControllerAddBytesSentCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerAddBytesSentCall) Return() *MockConnectionFlowControllerAddBytesSentCall {
-       c.Call = c.Call.Return()
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerAddBytesSentCall) Do(f func(protocol.ByteCount)) *MockConnectionFlowControllerAddBytesSentCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerAddBytesSentCall) DoAndReturn(f func(protocol.ByteCount)) *MockConnectionFlowControllerAddBytesSentCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
-
-// GetWindowUpdate mocks base method.
-func (m *MockConnectionFlowController) GetWindowUpdate(arg0 time.Time) protocol.ByteCount {
-       m.ctrl.T.Helper()
-       ret := m.ctrl.Call(m, "GetWindowUpdate", arg0)
-       ret0, _ := ret[0].(protocol.ByteCount)
-       return ret0
-}
-
-// GetWindowUpdate indicates an expected call of GetWindowUpdate.
-func (mr *MockConnectionFlowControllerMockRecorder) GetWindowUpdate(arg0 any) *MockConnectionFlowControllerGetWindowUpdateCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWindowUpdate", reflect.TypeOf((*MockConnectionFlowController)(nil).GetWindowUpdate), arg0)
-       return &MockConnectionFlowControllerGetWindowUpdateCall{Call: call}
-}
-
-// MockConnectionFlowControllerGetWindowUpdateCall wrap *gomock.Call
-type MockConnectionFlowControllerGetWindowUpdateCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerGetWindowUpdateCall) Return(arg0 protocol.ByteCount) *MockConnectionFlowControllerGetWindowUpdateCall {
-       c.Call = c.Call.Return(arg0)
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerGetWindowUpdateCall) Do(f func(time.Time) protocol.ByteCount) *MockConnectionFlowControllerGetWindowUpdateCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerGetWindowUpdateCall) DoAndReturn(f func(time.Time) protocol.ByteCount) *MockConnectionFlowControllerGetWindowUpdateCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
-
-// IsNewlyBlocked mocks base method.
-func (m *MockConnectionFlowController) IsNewlyBlocked() (bool, protocol.ByteCount) {
-       m.ctrl.T.Helper()
-       ret := m.ctrl.Call(m, "IsNewlyBlocked")
-       ret0, _ := ret[0].(bool)
-       ret1, _ := ret[1].(protocol.ByteCount)
-       return ret0, ret1
-}
-
-// IsNewlyBlocked indicates an expected call of IsNewlyBlocked.
-func (mr *MockConnectionFlowControllerMockRecorder) IsNewlyBlocked() *MockConnectionFlowControllerIsNewlyBlockedCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsNewlyBlocked", reflect.TypeOf((*MockConnectionFlowController)(nil).IsNewlyBlocked))
-       return &MockConnectionFlowControllerIsNewlyBlockedCall{Call: call}
-}
-
-// MockConnectionFlowControllerIsNewlyBlockedCall wrap *gomock.Call
-type MockConnectionFlowControllerIsNewlyBlockedCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerIsNewlyBlockedCall) Return(arg0 bool, arg1 protocol.ByteCount) *MockConnectionFlowControllerIsNewlyBlockedCall {
-       c.Call = c.Call.Return(arg0, arg1)
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerIsNewlyBlockedCall) Do(f func() (bool, protocol.ByteCount)) *MockConnectionFlowControllerIsNewlyBlockedCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerIsNewlyBlockedCall) DoAndReturn(f func() (bool, protocol.ByteCount)) *MockConnectionFlowControllerIsNewlyBlockedCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
-
-// Reset mocks base method.
-func (m *MockConnectionFlowController) Reset() error {
-       m.ctrl.T.Helper()
-       ret := m.ctrl.Call(m, "Reset")
-       ret0, _ := ret[0].(error)
-       return ret0
-}
-
-// Reset indicates an expected call of Reset.
-func (mr *MockConnectionFlowControllerMockRecorder) Reset() *MockConnectionFlowControllerResetCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reset", reflect.TypeOf((*MockConnectionFlowController)(nil).Reset))
-       return &MockConnectionFlowControllerResetCall{Call: call}
-}
-
-// MockConnectionFlowControllerResetCall wrap *gomock.Call
-type MockConnectionFlowControllerResetCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerResetCall) Return(arg0 error) *MockConnectionFlowControllerResetCall {
-       c.Call = c.Call.Return(arg0)
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerResetCall) Do(f func() error) *MockConnectionFlowControllerResetCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerResetCall) DoAndReturn(f func() error) *MockConnectionFlowControllerResetCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
-
-// SendWindowSize mocks base method.
-func (m *MockConnectionFlowController) SendWindowSize() protocol.ByteCount {
-       m.ctrl.T.Helper()
-       ret := m.ctrl.Call(m, "SendWindowSize")
-       ret0, _ := ret[0].(protocol.ByteCount)
-       return ret0
-}
-
-// SendWindowSize indicates an expected call of SendWindowSize.
-func (mr *MockConnectionFlowControllerMockRecorder) SendWindowSize() *MockConnectionFlowControllerSendWindowSizeCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendWindowSize", reflect.TypeOf((*MockConnectionFlowController)(nil).SendWindowSize))
-       return &MockConnectionFlowControllerSendWindowSizeCall{Call: call}
-}
-
-// MockConnectionFlowControllerSendWindowSizeCall wrap *gomock.Call
-type MockConnectionFlowControllerSendWindowSizeCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerSendWindowSizeCall) Return(arg0 protocol.ByteCount) *MockConnectionFlowControllerSendWindowSizeCall {
-       c.Call = c.Call.Return(arg0)
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerSendWindowSizeCall) Do(f func() protocol.ByteCount) *MockConnectionFlowControllerSendWindowSizeCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerSendWindowSizeCall) DoAndReturn(f func() protocol.ByteCount) *MockConnectionFlowControllerSendWindowSizeCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
-
-// UpdateSendWindow mocks base method.
-func (m *MockConnectionFlowController) UpdateSendWindow(arg0 protocol.ByteCount) bool {
-       m.ctrl.T.Helper()
-       ret := m.ctrl.Call(m, "UpdateSendWindow", arg0)
-       ret0, _ := ret[0].(bool)
-       return ret0
-}
-
-// UpdateSendWindow indicates an expected call of UpdateSendWindow.
-func (mr *MockConnectionFlowControllerMockRecorder) UpdateSendWindow(arg0 any) *MockConnectionFlowControllerUpdateSendWindowCall {
-       mr.mock.ctrl.T.Helper()
-       call := mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateSendWindow", reflect.TypeOf((*MockConnectionFlowController)(nil).UpdateSendWindow), arg0)
-       return &MockConnectionFlowControllerUpdateSendWindowCall{Call: call}
-}
-
-// MockConnectionFlowControllerUpdateSendWindowCall wrap *gomock.Call
-type MockConnectionFlowControllerUpdateSendWindowCall struct {
-       *gomock.Call
-}
-
-// Return rewrite *gomock.Call.Return
-func (c *MockConnectionFlowControllerUpdateSendWindowCall) Return(updated bool) *MockConnectionFlowControllerUpdateSendWindowCall {
-       c.Call = c.Call.Return(updated)
-       return c
-}
-
-// Do rewrite *gomock.Call.Do
-func (c *MockConnectionFlowControllerUpdateSendWindowCall) Do(f func(protocol.ByteCount) bool) *MockConnectionFlowControllerUpdateSendWindowCall {
-       c.Call = c.Call.Do(f)
-       return c
-}
-
-// DoAndReturn rewrite *gomock.Call.DoAndReturn
-func (c *MockConnectionFlowControllerUpdateSendWindowCall) DoAndReturn(f func(protocol.ByteCount) bool) *MockConnectionFlowControllerUpdateSendWindowCall {
-       c.Call = c.Call.DoAndReturn(f)
-       return c
-}
index edc58f4ea3c64bc6f4cb9e30c80020b669e3f6af..3a5a6642df249313bea57404aeae4108f8bc81eb 100644 (file)
@@ -8,6 +8,5 @@ package mocks
 //go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package mocks -destination crypto_setup.go github.com/quic-go/quic-go/internal/handshake CryptoSetup"
 //go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package mocks -destination stream_flow_controller.go github.com/quic-go/quic-go/internal/flowcontrol StreamFlowController"
 //go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package mocks -destination congestion.go github.com/quic-go/quic-go/internal/congestion SendAlgorithmWithDebugInfos"
-//go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package mocks -destination connection_flow_controller.go github.com/quic-go/quic-go/internal/flowcontrol ConnectionFlowController"
 //go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package mockackhandler -destination ackhandler/sent_packet_handler.go github.com/quic-go/quic-go/internal/ackhandler SentPacketHandler"
 //go:generate sh -c "go run go.uber.org/mock/mockgen -typed -build_flags=\"-tags=gomock\" -package mockackhandler -destination ackhandler/received_packet_handler.go github.com/quic-go/quic-go/internal/ackhandler ReceivedPacketHandler"