From 86338d3ce07f0e8bc817e535d1d8d3aaae509492 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 26 Mar 2022 15:31:31 +0100 Subject: [PATCH] rename the sessionRunner to connRunner --- client_test.go | 22 ++--- ...runner_test.go => mock_conn_runner_test.go | 64 +++++++-------- mockgen.go | 2 +- server.go | 4 +- server_test.go | 20 ++--- session.go | 6 +- session_test.go | 80 +++++++++---------- 7 files changed, 99 insertions(+), 99 deletions(-) rename mock_session_runner_test.go => mock_conn_runner_test.go (50%) diff --git a/client_test.go b/client_test.go index 351b4d6d..c055a75d 100644 --- a/client_test.go +++ b/client_test.go @@ -33,7 +33,7 @@ var _ = Describe("Client", func() { originalClientSessConstructor func( conn sendConn, - runner sessionRunner, + runner connRunner, destConnID protocol.ConnectionID, srcConnID protocol.ConnectionID, conf *Config, @@ -120,7 +120,7 @@ var _ = Describe("Client", func() { remoteAddrChan := make(chan string, 1) newClientSession = func( sconn sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -153,7 +153,7 @@ var _ = Describe("Client", func() { hostnameChan := make(chan string, 1) newClientSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -186,7 +186,7 @@ var _ = Describe("Client", func() { hostnameChan := make(chan string, 1) newClientSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -225,7 +225,7 @@ var _ = Describe("Client", func() { run := make(chan struct{}) newClientSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -268,7 +268,7 @@ var _ = Describe("Client", func() { done := make(chan struct{}) newClientSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -316,7 +316,7 @@ var _ = Describe("Client", func() { testErr := errors.New("early handshake error") newClientSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -359,7 +359,7 @@ var _ = Describe("Client", func() { conn.EXPECT().HandshakeComplete().Return(context.Background()) newClientSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -411,7 +411,7 @@ var _ = Describe("Client", func() { conn := NewMockQuicConn(mockCtrl) newClientSession = func( connP sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, _ *Config, @@ -531,7 +531,7 @@ var _ = Describe("Client", func() { var conf *Config newClientSession = func( connP sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, configP *Config, @@ -571,7 +571,7 @@ var _ = Describe("Client", func() { var counter int newClientSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, _ protocol.ConnectionID, _ protocol.ConnectionID, configP *Config, diff --git a/mock_session_runner_test.go b/mock_conn_runner_test.go similarity index 50% rename from mock_session_runner_test.go rename to mock_conn_runner_test.go index e51a1f80..1620b244 100644 --- a/mock_session_runner_test.go +++ b/mock_conn_runner_test.go @@ -11,31 +11,31 @@ import ( protocol "github.com/lucas-clemente/quic-go/internal/protocol" ) -// MockSessionRunner is a mock of SessionRunner interface. -type MockSessionRunner struct { +// MockConnRunner is a mock of ConnRunner interface. +type MockConnRunner struct { ctrl *gomock.Controller - recorder *MockSessionRunnerMockRecorder + recorder *MockConnRunnerMockRecorder } -// MockSessionRunnerMockRecorder is the mock recorder for MockSessionRunner. -type MockSessionRunnerMockRecorder struct { - mock *MockSessionRunner +// MockConnRunnerMockRecorder is the mock recorder for MockConnRunner. +type MockConnRunnerMockRecorder struct { + mock *MockConnRunner } -// NewMockSessionRunner creates a new mock instance. -func NewMockSessionRunner(ctrl *gomock.Controller) *MockSessionRunner { - mock := &MockSessionRunner{ctrl: ctrl} - mock.recorder = &MockSessionRunnerMockRecorder{mock} +// NewMockConnRunner creates a new mock instance. +func NewMockConnRunner(ctrl *gomock.Controller) *MockConnRunner { + mock := &MockConnRunner{ctrl: ctrl} + mock.recorder = &MockConnRunnerMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockSessionRunner) EXPECT() *MockSessionRunnerMockRecorder { +func (m *MockConnRunner) EXPECT() *MockConnRunnerMockRecorder { return m.recorder } // Add mocks base method. -func (m *MockSessionRunner) Add(arg0 protocol.ConnectionID, arg1 packetHandler) bool { +func (m *MockConnRunner) Add(arg0 protocol.ConnectionID, arg1 packetHandler) bool { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Add", arg0, arg1) ret0, _ := ret[0].(bool) @@ -43,25 +43,25 @@ func (m *MockSessionRunner) Add(arg0 protocol.ConnectionID, arg1 packetHandler) } // Add indicates an expected call of Add. -func (mr *MockSessionRunnerMockRecorder) Add(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) Add(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockSessionRunner)(nil).Add), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockConnRunner)(nil).Add), arg0, arg1) } // AddResetToken mocks base method. -func (m *MockSessionRunner) AddResetToken(arg0 protocol.StatelessResetToken, arg1 packetHandler) { +func (m *MockConnRunner) AddResetToken(arg0 protocol.StatelessResetToken, arg1 packetHandler) { m.ctrl.T.Helper() m.ctrl.Call(m, "AddResetToken", arg0, arg1) } // AddResetToken indicates an expected call of AddResetToken. -func (mr *MockSessionRunnerMockRecorder) AddResetToken(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) AddResetToken(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddResetToken", reflect.TypeOf((*MockSessionRunner)(nil).AddResetToken), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddResetToken", reflect.TypeOf((*MockConnRunner)(nil).AddResetToken), arg0, arg1) } // GetStatelessResetToken mocks base method. -func (m *MockSessionRunner) GetStatelessResetToken(arg0 protocol.ConnectionID) protocol.StatelessResetToken { +func (m *MockConnRunner) GetStatelessResetToken(arg0 protocol.ConnectionID) protocol.StatelessResetToken { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStatelessResetToken", arg0) ret0, _ := ret[0].(protocol.StatelessResetToken) @@ -69,55 +69,55 @@ func (m *MockSessionRunner) GetStatelessResetToken(arg0 protocol.ConnectionID) p } // GetStatelessResetToken indicates an expected call of GetStatelessResetToken. -func (mr *MockSessionRunnerMockRecorder) GetStatelessResetToken(arg0 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) GetStatelessResetToken(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatelessResetToken", reflect.TypeOf((*MockSessionRunner)(nil).GetStatelessResetToken), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStatelessResetToken", reflect.TypeOf((*MockConnRunner)(nil).GetStatelessResetToken), arg0) } // Remove mocks base method. -func (m *MockSessionRunner) Remove(arg0 protocol.ConnectionID) { +func (m *MockConnRunner) Remove(arg0 protocol.ConnectionID) { m.ctrl.T.Helper() m.ctrl.Call(m, "Remove", arg0) } // Remove indicates an expected call of Remove. -func (mr *MockSessionRunnerMockRecorder) Remove(arg0 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) Remove(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockSessionRunner)(nil).Remove), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockConnRunner)(nil).Remove), arg0) } // RemoveResetToken mocks base method. -func (m *MockSessionRunner) RemoveResetToken(arg0 protocol.StatelessResetToken) { +func (m *MockConnRunner) RemoveResetToken(arg0 protocol.StatelessResetToken) { m.ctrl.T.Helper() m.ctrl.Call(m, "RemoveResetToken", arg0) } // RemoveResetToken indicates an expected call of RemoveResetToken. -func (mr *MockSessionRunnerMockRecorder) RemoveResetToken(arg0 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) RemoveResetToken(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveResetToken", reflect.TypeOf((*MockSessionRunner)(nil).RemoveResetToken), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveResetToken", reflect.TypeOf((*MockConnRunner)(nil).RemoveResetToken), arg0) } // ReplaceWithClosed mocks base method. -func (m *MockSessionRunner) ReplaceWithClosed(arg0 protocol.ConnectionID, arg1 packetHandler) { +func (m *MockConnRunner) ReplaceWithClosed(arg0 protocol.ConnectionID, arg1 packetHandler) { m.ctrl.T.Helper() m.ctrl.Call(m, "ReplaceWithClosed", arg0, arg1) } // ReplaceWithClosed indicates an expected call of ReplaceWithClosed. -func (mr *MockSessionRunnerMockRecorder) ReplaceWithClosed(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) ReplaceWithClosed(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReplaceWithClosed", reflect.TypeOf((*MockSessionRunner)(nil).ReplaceWithClosed), arg0, arg1) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReplaceWithClosed", reflect.TypeOf((*MockConnRunner)(nil).ReplaceWithClosed), arg0, arg1) } // Retire mocks base method. -func (m *MockSessionRunner) Retire(arg0 protocol.ConnectionID) { +func (m *MockConnRunner) Retire(arg0 protocol.ConnectionID) { m.ctrl.T.Helper() m.ctrl.Call(m, "Retire", arg0) } // Retire indicates an expected call of Retire. -func (mr *MockSessionRunnerMockRecorder) Retire(arg0 interface{}) *gomock.Call { +func (mr *MockConnRunnerMockRecorder) Retire(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Retire", reflect.TypeOf((*MockSessionRunner)(nil).Retire), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Retire", reflect.TypeOf((*MockConnRunner)(nil).Retire), arg0) } diff --git a/mockgen.go b/mockgen.go index ba43fd1e..22c2c0e7 100644 --- a/mockgen.go +++ b/mockgen.go @@ -16,7 +16,7 @@ package quic //go:generate sh -c "./mockgen_private.sh quic mock_unpacker_test.go github.com/lucas-clemente/quic-go unpacker" //go:generate sh -c "./mockgen_private.sh quic mock_packer_test.go github.com/lucas-clemente/quic-go packer" //go:generate sh -c "./mockgen_private.sh quic mock_mtu_discoverer_test.go github.com/lucas-clemente/quic-go mtuDiscoverer" -//go:generate sh -c "./mockgen_private.sh quic mock_session_runner_test.go github.com/lucas-clemente/quic-go sessionRunner" +//go:generate sh -c "./mockgen_private.sh quic mock_conn_runner_test.go github.com/lucas-clemente/quic-go connRunner" //go:generate sh -c "./mockgen_private.sh quic mock_quic_conn_test.go github.com/lucas-clemente/quic-go quicConn" //go:generate sh -c "./mockgen_private.sh quic mock_packet_handler_test.go github.com/lucas-clemente/quic-go packetHandler" //go:generate sh -c "./mockgen_private.sh quic mock_unknown_packet_handler_test.go github.com/lucas-clemente/quic-go unknownPacketHandler" diff --git a/server.go b/server.go index d240eaf1..d6f89836 100644 --- a/server.go +++ b/server.go @@ -36,7 +36,7 @@ type unknownPacketHandler interface { type packetHandlerManager interface { AddWithConnID(protocol.ConnectionID, protocol.ConnectionID, func() packetHandler) bool Destroy() error - sessionRunner + connRunner SetServer(unknownPacketHandler) CloseServer() } @@ -75,7 +75,7 @@ type baseServer struct { // set as a member, so they can be set in the tests newSession func( sendConn, - sessionRunner, + connRunner, protocol.ConnectionID, /* original dest connection ID */ *protocol.ConnectionID, /* retry src connection ID */ protocol.ConnectionID, /* client dest connection ID */ diff --git a/server_test.go b/server_test.go index dc953099..798185f4 100644 --- a/server_test.go +++ b/server_test.go @@ -326,7 +326,7 @@ var _ = Describe("Server", func() { conn := NewMockQuicConn(mockCtrl) serv.newSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, origDestConnID protocol.ConnectionID, retrySrcConnID *protocol.ConnectionID, clientDestConnID protocol.ConnectionID, @@ -605,7 +605,7 @@ var _ = Describe("Server", func() { conn := NewMockQuicConn(mockCtrl) serv.newSession = func( _ sendConn, - _ sessionRunner, + _ connRunner, origDestConnID protocol.ConnectionID, retrySrcConnID *protocol.ConnectionID, clientDestConnID protocol.ConnectionID, @@ -665,7 +665,7 @@ var _ = Describe("Server", func() { var counter uint32 // to be used as an atomic, so we query it in Eventually serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -719,7 +719,7 @@ var _ = Describe("Server", func() { conn := NewMockQuicConn(mockCtrl) serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -750,7 +750,7 @@ var _ = Describe("Server", func() { serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -822,7 +822,7 @@ var _ = Describe("Server", func() { conn := NewMockQuicConn(mockCtrl) serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -934,7 +934,7 @@ var _ = Describe("Server", func() { serv.config.AcceptToken = func(_ net.Addr, _ *Token) bool { return true } serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -1008,7 +1008,7 @@ var _ = Describe("Server", func() { serv.config.AcceptToken = func(_ net.Addr, _ *Token) bool { return true } serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -1051,7 +1051,7 @@ var _ = Describe("Server", func() { serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, @@ -1115,7 +1115,7 @@ var _ = Describe("Server", func() { conn := NewMockQuicConn(mockCtrl) serv.newSession = func( _ sendConn, - runner sessionRunner, + runner connRunner, _ protocol.ConnectionID, _ *protocol.ConnectionID, _ protocol.ConnectionID, diff --git a/session.go b/session.go index c8df0c78..1062edd4 100644 --- a/session.go +++ b/session.go @@ -90,7 +90,7 @@ func (p *receivedPacket) Clone() *receivedPacket { } } -type sessionRunner interface { +type connRunner interface { Add(protocol.ConnectionID, packetHandler) bool GetStatelessResetToken(protocol.ConnectionID) protocol.StatelessResetToken Retire(protocol.ConnectionID) @@ -230,7 +230,7 @@ var ( var newSession = func( conn sendConn, - runner sessionRunner, + runner connRunner, origDestConnID protocol.ConnectionID, retrySrcConnID *protocol.ConnectionID, clientDestConnID protocol.ConnectionID, @@ -364,7 +364,7 @@ var newSession = func( // declare this as a variable, such that we can it mock it in the tests var newClientSession = func( conn sendConn, - runner sessionRunner, + runner connRunner, destConnID protocol.ConnectionID, srcConnID protocol.ConnectionID, conf *Config, diff --git a/session_test.go b/session_test.go index 9763ead9..5ddf0b4c 100644 --- a/session_test.go +++ b/session_test.go @@ -46,7 +46,7 @@ func areClosedConnsRunning() bool { var _ = Describe("Connection", func() { var ( sess *session - sessionRunner *MockSessionRunner + connRunner *MockConnRunner mconn *MockSendConn streamManager *MockStreamManager packer *MockPacker @@ -72,8 +72,8 @@ var _ = Describe("Connection", func() { } expectReplaceWithClosed := func() { - sessionRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).MaxTimes(1) - sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).MaxTimes(1) + connRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { Expect(s).To(BeAssignableToTypeOf(&closedLocalConn{})) s.shutdown() Eventually(areClosedConnsRunning).Should(BeFalse()) @@ -83,7 +83,7 @@ var _ = Describe("Connection", func() { BeforeEach(func() { Eventually(areSessionsRunning).Should(BeFalse()) - sessionRunner = NewMockSessionRunner(mockCtrl) + connRunner = NewMockConnRunner(mockCtrl) mconn = NewMockSendConn(mockCtrl) mconn.EXPECT().RemoteAddr().Return(remoteAddr).AnyTimes() mconn.EXPECT().LocalAddr().Return(localAddr).AnyTimes() @@ -96,7 +96,7 @@ var _ = Describe("Connection", func() { tracer.EXPECT().UpdatedCongestionState(gomock.Any()) sess = newSession( mconn, - sessionRunner, + connRunner, nil, nil, clientDestConnID, @@ -329,10 +329,10 @@ var _ = Describe("Connection", func() { ErrorMessage: "foobar", } streamManager.EXPECT().CloseWithError(expectedErr) - sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { Expect(s).To(BeAssignableToTypeOf(&closedRemoteConn{})) }) - sessionRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { Expect(s).To(BeAssignableToTypeOf(&closedRemoteConn{})) }) cryptoSetup.EXPECT().Close() @@ -360,10 +360,10 @@ var _ = Describe("Connection", func() { ErrorMessage: "foobar", } streamManager.EXPECT().CloseWithError(testErr) - sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { Expect(s).To(BeAssignableToTypeOf(&closedRemoteConn{})) }) - sessionRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(clientDestConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { Expect(s).To(BeAssignableToTypeOf(&closedRemoteConn{})) }) cryptoSetup.EXPECT().Close() @@ -515,7 +515,7 @@ var _ = Describe("Connection", func() { runSession() testErr := errors.New("close") streamManager.EXPECT().CloseWithError(gomock.Any()) - sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes() + connRunner.EXPECT().Remove(gomock.Any()).AnyTimes() cryptoSetup.EXPECT().Close() // don't EXPECT any calls to mconn.Write() gomock.InOrder( @@ -564,7 +564,7 @@ var _ = Describe("Connection", func() { runSession() cryptoSetup.EXPECT().Close() streamManager.EXPECT().CloseWithError(gomock.Any()) - sessionRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).AnyTimes() + connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).AnyTimes() buf := &bytes.Buffer{} hdr := &wire.ExtendedHeader{ Header: wire.Header{DestConnectionID: srcConnID}, @@ -612,7 +612,7 @@ var _ = Describe("Connection", func() { tracer.EXPECT().ClosedConnection(gomock.Any()) tracer.EXPECT().Close() streamManager.EXPECT().CloseWithError(gomock.Any()) - sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes() + connRunner.EXPECT().Remove(gomock.Any()).AnyTimes() cryptoSetup.EXPECT().Close() sess.sentPacketHandler = sph p := getPacket(1) @@ -636,7 +636,7 @@ var _ = Describe("Connection", func() { tracer.EXPECT().Close(), ) streamManager.EXPECT().CloseWithError(gomock.Any()) - sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes() + connRunner.EXPECT().Remove(gomock.Any()).AnyTimes() cryptoSetup.EXPECT().Close() sess.destroy(&StatelessResetError{Token: token}) }) @@ -1881,7 +1881,7 @@ var _ = Describe("Connection", func() { sph.EXPECT().TimeUntilSend().AnyTimes() sph.EXPECT().SendMode().AnyTimes() sph.EXPECT().SetHandshakeConfirmed() - sessionRunner.EXPECT().Retire(clientDestConnID) + connRunner.EXPECT().Retire(clientDestConnID) go func() { defer GinkgoRecover() <-finishHandshake @@ -1911,7 +1911,7 @@ var _ = Describe("Connection", func() { const size = protocol.MaxPostHandshakeCryptoFrameSize * 3 / 2 packer.EXPECT().PackCoalescedPacket().AnyTimes() finishHandshake := make(chan struct{}) - sessionRunner.EXPECT().Retire(clientDestConnID) + connRunner.EXPECT().Retire(clientDestConnID) go func() { defer GinkgoRecover() <-finishHandshake @@ -1985,7 +1985,7 @@ var _ = Describe("Connection", func() { tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()) sess.sentPacketHandler = sph done := make(chan struct{}) - sessionRunner.EXPECT().Retire(clientDestConnID) + connRunner.EXPECT().Retire(clientDestConnID) packer.EXPECT().PackPacket().DoAndReturn(func() (*packedPacket, error) { frames, _ := sess.framer.AppendControlFrames(nil, protocol.MaxByteCount) Expect(frames).ToNot(BeEmpty()) @@ -2078,8 +2078,8 @@ var _ = Describe("Connection", func() { packer.EXPECT().HandleTransportParameters(params) 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) + connRunner.EXPECT().GetStatelessResetToken(gomock.Any()).Times(2) + connRunner.EXPECT().Add(gomock.Any(), sess).Times(2) tracer.EXPECT().ReceivedTransportParameters(params) sess.handleTransportParameters(params) Expect(sess.earlySessionReady()).To(BeClosed()) @@ -2176,7 +2176,7 @@ var _ = Describe("Connection", func() { }) It("times out due to no network activity", func() { - sessionRunner.EXPECT().Remove(gomock.Any()).Times(2) + connRunner.EXPECT().Remove(gomock.Any()).Times(2) sess.lastPacketReceivedTime = time.Now().Add(-time.Hour) done := make(chan struct{}) cryptoSetup.EXPECT().Close() @@ -2202,7 +2202,7 @@ var _ = Describe("Connection", func() { It("times out due to non-completed handshake", func() { sess.handshakeComplete = false sess.sessionCreationTime = time.Now().Add(-protocol.DefaultHandshakeTimeout).Add(-time.Second) - sessionRunner.EXPECT().Remove(gomock.Any()).Times(2) + connRunner.EXPECT().Remove(gomock.Any()).Times(2) cryptoSetup.EXPECT().Close() gomock.InOrder( tracer.EXPECT().ClosedConnection(gomock.Any()).Do(func(e error) { @@ -2261,7 +2261,7 @@ var _ = Describe("Connection", func() { It("closes the session due to the idle timeout before handshake", func() { sess.config.HandshakeIdleTimeout = 0 packer.EXPECT().PackCoalescedPacket().AnyTimes() - sessionRunner.EXPECT().Remove(gomock.Any()).AnyTimes() + connRunner.EXPECT().Remove(gomock.Any()).AnyTimes() cryptoSetup.EXPECT().Close() gomock.InOrder( tracer.EXPECT().ClosedConnection(gomock.Any()).Do(func(e error) { @@ -2288,8 +2288,8 @@ var _ = Describe("Connection", func() { It("closes the session due to the idle timeout after handshake", func() { packer.EXPECT().PackCoalescedPacket().AnyTimes() gomock.InOrder( - sessionRunner.EXPECT().Retire(clientDestConnID), - sessionRunner.EXPECT().Remove(gomock.Any()), + connRunner.EXPECT().Retire(clientDestConnID), + connRunner.EXPECT().Remove(gomock.Any()), ) cryptoSetup.EXPECT().Close() gomock.InOrder( @@ -2415,14 +2415,14 @@ var _ = Describe("Connection", func() { var _ = Describe("Client Connection", func() { var ( - sess *session - sessionRunner *MockSessionRunner - packer *MockPacker - mconn *MockSendConn - cryptoSetup *mocks.MockCryptoSetup - tracer *mocklogging.MockConnectionTracer - tlsConf *tls.Config - quicConf *Config + sess *session + connRunner *MockConnRunner + packer *MockPacker + mconn *MockSendConn + cryptoSetup *mocks.MockCryptoSetup + tracer *mocklogging.MockConnectionTracer + tlsConf *tls.Config + quicConf *Config ) srcConnID := protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8} destConnID := protocol.ConnectionID{8, 7, 6, 5, 4, 3, 2, 1} @@ -2437,7 +2437,7 @@ var _ = Describe("Client Connection", func() { } expectReplaceWithClosed := func() { - sessionRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(srcConnID, gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { s.shutdown() Eventually(areClosedConnsRunning).Should(BeFalse()) }) @@ -2457,7 +2457,7 @@ var _ = Describe("Client Connection", func() { if tlsConf == nil { tlsConf = &tls.Config{} } - sessionRunner = NewMockSessionRunner(mockCtrl) + connRunner = NewMockConnRunner(mockCtrl) tracer = mocklogging.NewMockConnectionTracer(mockCtrl) tracer.EXPECT().NegotiatedVersion(gomock.Any(), gomock.Any(), gomock.Any()).MaxTimes(1) tracer.EXPECT().SentTransportParameters(gomock.Any()) @@ -2465,7 +2465,7 @@ var _ = Describe("Client Connection", func() { tracer.EXPECT().UpdatedCongestionState(gomock.Any()) sess = newClientSession( mconn, - sessionRunner, + connRunner, destConnID, protocol.ConnectionID{1, 2, 3, 4, 5, 6, 7, 8}, quicConf, @@ -2527,7 +2527,7 @@ var _ = Describe("Client Connection", func() { It("continues accepting Long Header packets after using a new connection ID", func() { unpacker := NewMockUnpacker(mockCtrl) sess.unpacker = unpacker - sessionRunner.EXPECT().AddResetToken(gomock.Any(), gomock.Any()) + connRunner.EXPECT().AddResetToken(gomock.Any(), gomock.Any()) sess.connIDManager.SetHandshakeComplete() sess.handleNewConnectionIDFrame(&wire.NewConnectionIDFrame{ SequenceNumber: 1, @@ -2612,7 +2612,7 @@ var _ = Describe("Client Connection", func() { cryptoSetup.EXPECT().RunHandshake().MaxTimes(1) errChan <- sess.run() }() - sessionRunner.EXPECT().Remove(srcConnID) + connRunner.EXPECT().Remove(srcConnID) tracer.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any(), gomock.Any()).Do(func(hdr *wire.Header, versions []logging.VersionNumber) { Expect(hdr.Version).To(BeZero()) Expect(versions).To(And( @@ -2638,7 +2638,7 @@ var _ = Describe("Client Connection", func() { cryptoSetup.EXPECT().RunHandshake().MaxTimes(1) errChan <- sess.run() }() - sessionRunner.EXPECT().Remove(srcConnID).MaxTimes(1) + connRunner.EXPECT().Remove(srcConnID).MaxTimes(1) gomock.InOrder( tracer.EXPECT().ReceivedVersionNegotiationPacket(gomock.Any(), gomock.Any()), tracer.EXPECT().ClosedConnection(gomock.Any()).Do(func(e error) { @@ -2752,7 +2752,7 @@ var _ = Describe("Client Connection", func() { expectClose := func(applicationClose bool) { if !closed { - sessionRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { + connRunner.EXPECT().ReplaceWithClosed(gomock.Any(), gomock.Any()).Do(func(_ protocol.ConnectionID, s packetHandler) { Expect(s).To(BeAssignableToTypeOf(&closedLocalConn{})) s.shutdown() }) @@ -2796,10 +2796,10 @@ var _ = Describe("Client Connection", func() { // make sure the connection ID is not retired cf, _ := sess.framer.AppendControlFrames(nil, protocol.MaxByteCount) Expect(cf).To(BeEmpty()) - sessionRunner.EXPECT().AddResetToken(protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, sess) + connRunner.EXPECT().AddResetToken(protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}, sess) Expect(sess.connIDManager.Get()).To(Equal(protocol.ConnectionID{1, 2, 3, 4})) // shut down - sessionRunner.EXPECT().RemoveResetToken(protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) + connRunner.EXPECT().RemoveResetToken(protocol.StatelessResetToken{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}) expectClose(true) })