diff --git a/api/admin/service_test.go b/api/admin/service_test.go index 09665a52c9d9..774c93440bc9 100644 --- a/api/admin/service_test.go +++ b/api/admin/service_test.go @@ -20,7 +20,6 @@ import ( type loadVMsTest struct { admin *Admin ctrl *gomock.Controller - mockLog *logging.MockLogger mockVMManager *vms.MockManager mockVMRegistry *registry.MockVMRegistry } @@ -28,18 +27,16 @@ type loadVMsTest struct { func initLoadVMsTest(t *testing.T) *loadVMsTest { ctrl := gomock.NewController(t) - mockLog := logging.NewMockLogger(ctrl) mockVMRegistry := registry.NewMockVMRegistry(ctrl) mockVMManager := vms.NewMockManager(ctrl) return &loadVMsTest{ admin: &Admin{Config: Config{ - Log: mockLog, + Log: logging.NoLog{}, VMRegistry: mockVMRegistry, VMManager: mockVMManager, }}, ctrl: ctrl, - mockLog: mockLog, mockVMManager: mockVMManager, mockVMRegistry: mockVMRegistry, } @@ -67,7 +64,6 @@ func TestLoadVMsSuccess(t *testing.T) { id2: alias2[1:], } - resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1) resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil) resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil) resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil) @@ -84,7 +80,6 @@ func TestLoadVMsReloadFails(t *testing.T) { resources := initLoadVMsTest(t) - resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1) // Reload fails resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(nil, nil, errTest) @@ -108,7 +103,6 @@ func TestLoadVMsGetAliasesFails(t *testing.T) { // every vm is at least aliased to itself. alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"} - resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1) resources.mockVMRegistry.EXPECT().ReloadWithReadLock(gomock.Any()).Times(1).Return(newVMs, failedVMs, nil) resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil) resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest) diff --git a/api/info/service_test.go b/api/info/service_test.go index 312d8182ea83..ad6320df5a90 100644 --- a/api/info/service_test.go +++ b/api/info/service_test.go @@ -21,24 +21,20 @@ var errTest = errors.New("non-nil error") type getVMsTest struct { info *Info ctrl *gomock.Controller - mockLog *logging.MockLogger mockVMManager *vms.MockManager } func initGetVMsTest(t *testing.T) *getVMsTest { ctrl := gomock.NewController(t) - - service := Info{} - mockLog := logging.NewMockLogger(ctrl) mockVMManager := vms.NewMockManager(ctrl) - - service.log = mockLog - service.VMManager = mockVMManager - return &getVMsTest{ - info: &service, + info: &Info{ + Parameters: Parameters{ + VMManager: mockVMManager, + }, + log: logging.NoLog{}, + }, ctrl: ctrl, - mockLog: mockLog, mockVMManager: mockVMManager, } } @@ -62,7 +58,6 @@ func TestGetVMsSuccess(t *testing.T) { id2: alias2[1:], } - resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1) resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(vmIDs, nil) resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil) resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(alias2, nil) @@ -76,7 +71,6 @@ func TestGetVMsSuccess(t *testing.T) { func TestGetVMsVMsListFactoriesFails(t *testing.T) { resources := initGetVMsTest(t) - resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1) resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(nil, errTest) reply := GetVMsReply{} @@ -93,7 +87,6 @@ func TestGetVMsGetAliasesFails(t *testing.T) { vmIDs := []ids.ID{id1, id2} alias1 := []string{id1.String(), "vm1-alias-1", "vm1-alias-2"} - resources.mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).Times(1) resources.mockVMManager.EXPECT().ListFactories().Times(1).Return(vmIDs, nil) resources.mockVMManager.EXPECT().Aliases(id1).Times(1).Return(alias1, nil) resources.mockVMManager.EXPECT().Aliases(id2).Times(1).Return(nil, errTest) diff --git a/scripts/mocks.mockgen.txt b/scripts/mocks.mockgen.txt index c01efb8e5869..2fbfa5b255ab 100644 --- a/scripts/mocks.mockgen.txt +++ b/scripts/mocks.mockgen.txt @@ -21,7 +21,6 @@ github.com/ava-labs/avalanchego/snow/validators=SubnetConnector=snow/validators/ github.com/ava-labs/avalanchego/utils/crypto/keychain=Ledger=utils/crypto/keychain/mock_ledger.go github.com/ava-labs/avalanchego/utils/filesystem=Reader=utils/filesystem/mock_io.go github.com/ava-labs/avalanchego/utils/hashing=Hasher=utils/hashing/mock_hasher.go -github.com/ava-labs/avalanchego/utils/logging=Logger=utils/logging/mock_logger.go github.com/ava-labs/avalanchego/utils/resource=User=utils/resource/mock_user.go github.com/ava-labs/avalanchego/vms/avm/block=Block=vms/avm/block/mock_block.go github.com/ava-labs/avalanchego/vms/avm/metrics=Metrics=vms/avm/metrics/mock_metrics.go diff --git a/utils/logging/mock_logger.go b/utils/logging/mock_logger.go deleted file mode 100644 index ba1079d30a09..000000000000 --- a/utils/logging/mock_logger.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved. -// See the file LICENSE for licensing terms. - -// Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/avalanchego/utils/logging (interfaces: Logger) - -// Package logging is a generated GoMock package. -package logging - -import ( - reflect "reflect" - - gomock "go.uber.org/mock/gomock" - zapcore "go.uber.org/zap/zapcore" -) - -// MockLogger is a mock of Logger interface. -type MockLogger struct { - ctrl *gomock.Controller - recorder *MockLoggerMockRecorder -} - -// MockLoggerMockRecorder is the mock recorder for MockLogger. -type MockLoggerMockRecorder struct { - mock *MockLogger -} - -// NewMockLogger creates a new mock instance. -func NewMockLogger(ctrl *gomock.Controller) *MockLogger { - mock := &MockLogger{ctrl: ctrl} - mock.recorder = &MockLoggerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockLogger) EXPECT() *MockLoggerMockRecorder { - return m.recorder -} - -// Debug mocks base method. -func (m *MockLogger) Debug(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Debug", varargs...) -} - -// Debug indicates an expected call of Debug. -func (mr *MockLoggerMockRecorder) Debug(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Debug", reflect.TypeOf((*MockLogger)(nil).Debug), varargs...) -} - -// Enabled mocks base method. -func (m *MockLogger) Enabled(arg0 Level) bool { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Enabled", arg0) - ret0, _ := ret[0].(bool) - return ret0 -} - -// Enabled indicates an expected call of Enabled. -func (mr *MockLoggerMockRecorder) Enabled(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Enabled", reflect.TypeOf((*MockLogger)(nil).Enabled), arg0) -} - -// Error mocks base method. -func (m *MockLogger) Error(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Error", varargs...) -} - -// Error indicates an expected call of Error. -func (mr *MockLoggerMockRecorder) Error(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Error", reflect.TypeOf((*MockLogger)(nil).Error), varargs...) -} - -// Fatal mocks base method. -func (m *MockLogger) Fatal(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Fatal", varargs...) -} - -// Fatal indicates an expected call of Fatal. -func (mr *MockLoggerMockRecorder) Fatal(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Fatal", reflect.TypeOf((*MockLogger)(nil).Fatal), varargs...) -} - -// Info mocks base method. -func (m *MockLogger) Info(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Info", varargs...) -} - -// Info indicates an expected call of Info. -func (mr *MockLoggerMockRecorder) Info(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Info", reflect.TypeOf((*MockLogger)(nil).Info), varargs...) -} - -// RecoverAndExit mocks base method. -func (m *MockLogger) RecoverAndExit(arg0, arg1 func()) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RecoverAndExit", arg0, arg1) -} - -// RecoverAndExit indicates an expected call of RecoverAndExit. -func (mr *MockLoggerMockRecorder) RecoverAndExit(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverAndExit", reflect.TypeOf((*MockLogger)(nil).RecoverAndExit), arg0, arg1) -} - -// RecoverAndPanic mocks base method. -func (m *MockLogger) RecoverAndPanic(arg0 func()) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RecoverAndPanic", arg0) -} - -// RecoverAndPanic indicates an expected call of RecoverAndPanic. -func (mr *MockLoggerMockRecorder) RecoverAndPanic(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecoverAndPanic", reflect.TypeOf((*MockLogger)(nil).RecoverAndPanic), arg0) -} - -// SetLevel mocks base method. -func (m *MockLogger) SetLevel(arg0 Level) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetLevel", arg0) -} - -// SetLevel indicates an expected call of SetLevel. -func (mr *MockLoggerMockRecorder) SetLevel(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLevel", reflect.TypeOf((*MockLogger)(nil).SetLevel), arg0) -} - -// Stop mocks base method. -func (m *MockLogger) Stop() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Stop") -} - -// Stop indicates an expected call of Stop. -func (mr *MockLoggerMockRecorder) Stop() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockLogger)(nil).Stop)) -} - -// StopOnPanic mocks base method. -func (m *MockLogger) StopOnPanic() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "StopOnPanic") -} - -// StopOnPanic indicates an expected call of StopOnPanic. -func (mr *MockLoggerMockRecorder) StopOnPanic() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopOnPanic", reflect.TypeOf((*MockLogger)(nil).StopOnPanic)) -} - -// Trace mocks base method. -func (m *MockLogger) Trace(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Trace", varargs...) -} - -// Trace indicates an expected call of Trace. -func (mr *MockLoggerMockRecorder) Trace(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trace", reflect.TypeOf((*MockLogger)(nil).Trace), varargs...) -} - -// Verbo mocks base method. -func (m *MockLogger) Verbo(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Verbo", varargs...) -} - -// Verbo indicates an expected call of Verbo. -func (mr *MockLoggerMockRecorder) Verbo(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Verbo", reflect.TypeOf((*MockLogger)(nil).Verbo), varargs...) -} - -// Warn mocks base method. -func (m *MockLogger) Warn(arg0 string, arg1 ...zapcore.Field) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0} - for _, a := range arg1 { - varargs = append(varargs, a) - } - m.ctrl.Call(m, "Warn", varargs...) -} - -// Warn indicates an expected call of Warn. -func (mr *MockLoggerMockRecorder) Warn(arg0 interface{}, arg1 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0}, arg1...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Warn", reflect.TypeOf((*MockLogger)(nil).Warn), varargs...) -} - -// Write mocks base method. -func (m *MockLogger) Write(arg0 []byte) (int, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Write", arg0) - ret0, _ := ret[0].(int) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Write indicates an expected call of Write. -func (mr *MockLoggerMockRecorder) Write(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockLogger)(nil).Write), arg0) -} diff --git a/vms/registry/vm_registerer_test.go b/vms/registry/vm_registerer_test.go index baaa569a89ba..f5ad6c2f1349 100644 --- a/vms/registry/vm_registerer_test.go +++ b/vms/registry/vm_registerer_test.go @@ -411,7 +411,6 @@ type vmRegistererTestResources struct { ctrl *gomock.Controller mockManager *vms.MockManager mockServer *server.MockServer - mockLogger *logging.MockLogger registerer VMRegisterer } @@ -420,27 +419,18 @@ func initRegistererTest(t *testing.T) *vmRegistererTestResources { mockManager := vms.NewMockManager(ctrl) mockServer := server.NewMockServer(ctrl) - mockLog := logging.NewMockLogger(ctrl) registerer := NewVMRegisterer(VMRegistererConfig{ APIServer: mockServer, - Log: mockLog, + Log: logging.NoLog{}, VMFactoryLog: logging.NoLog{}, VMManager: mockManager, }) - mockLog.EXPECT().Error(gomock.Any(), gomock.Any()).AnyTimes() - mockLog.EXPECT().Warn(gomock.Any(), gomock.Any()).AnyTimes() - mockLog.EXPECT().Info(gomock.Any(), gomock.Any()).AnyTimes() - mockLog.EXPECT().Debug(gomock.Any(), gomock.Any()).AnyTimes() - mockLog.EXPECT().Trace(gomock.Any(), gomock.Any()).AnyTimes() - mockLog.EXPECT().Verbo(gomock.Any(), gomock.Any()).AnyTimes() - return &vmRegistererTestResources{ ctrl: ctrl, mockManager: mockManager, mockServer: mockServer, - mockLogger: mockLog, registerer: registerer, } }