From 68986d301a0e7f7b50238ccef8daf54e364cec41 Mon Sep 17 00:00:00 2001 From: Dhruba Basu <7675102+dhrubabasu@users.noreply.github.com> Date: Wed, 17 Jan 2024 10:33:39 -0500 Subject: [PATCH] `x/sync`: Auto-generate `MockNetworkClient` (#2617) --- scripts/mocks.mockgen.txt | 1 + x/sync/client_test.go | 3 --- x/sync/mock_network_client.go | 32 ++++++++++---------------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/scripts/mocks.mockgen.txt b/scripts/mocks.mockgen.txt index c3bb7d3ffd24..84c44c2966e6 100644 --- a/scripts/mocks.mockgen.txt +++ b/scripts/mocks.mockgen.txt @@ -42,3 +42,4 @@ github.com/ava-labs/avalanchego/vms/registry=VMRegisterer=vms/registry/mock_vm_r github.com/ava-labs/avalanchego/vms/registry=VMRegistry=vms/registry/mock_vm_registry.go github.com/ava-labs/avalanchego/vms=Factory,Manager=vms/mock_manager.go github.com/ava-labs/avalanchego/x/sync=Client=x/sync/mock_client.go +github.com/ava-labs/avalanchego/x/sync=NetworkClient=x/sync/mock_network_client.go diff --git a/x/sync/client_test.go b/x/sync/client_test.go index e81d1a44010c..d394aa654c14 100644 --- a/x/sync/client_test.go +++ b/x/sync/client_test.go @@ -123,9 +123,6 @@ func sendRangeProofRequest( }, ).AnyTimes() - // Handle bandwidth tracking calls from client. - networkClient.EXPECT().TrackBandwidth(gomock.Any(), gomock.Any()).AnyTimes() - // The server should expect to "send" a response to the client. sender.EXPECT().SendAppResponse( gomock.Any(), // ctx diff --git a/x/sync/mock_network_client.go b/x/sync/mock_network_client.go index 8021a015f062..027b4f549366 100644 --- a/x/sync/mock_network_client.go +++ b/x/sync/mock_network_client.go @@ -1,7 +1,7 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: x/sync/network_client.go +// Source: github.com/ava-labs/avalanchego/x/sync (interfaces: NetworkClient) -// Package mock_sync is a generated GoMock package. +// Package sync is a generated GoMock package. package sync import ( @@ -93,24 +93,24 @@ func (mr *MockNetworkClientMockRecorder) Disconnected(arg0, arg1 interface{}) *g } // Request mocks base method. -func (m *MockNetworkClient) Request(ctx context.Context, nodeID ids.NodeID, request []byte) ([]byte, error) { +func (m *MockNetworkClient) Request(arg0 context.Context, arg1 ids.NodeID, arg2 []byte) ([]byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Request", ctx, nodeID, request) + ret := m.ctrl.Call(m, "Request", arg0, arg1, arg2) ret0, _ := ret[0].([]byte) ret1, _ := ret[1].(error) return ret0, ret1 } // Request indicates an expected call of Request. -func (mr *MockNetworkClientMockRecorder) Request(ctx, nodeID, request interface{}) *gomock.Call { +func (mr *MockNetworkClientMockRecorder) Request(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Request", reflect.TypeOf((*MockNetworkClient)(nil).Request), ctx, nodeID, request) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Request", reflect.TypeOf((*MockNetworkClient)(nil).Request), arg0, arg1, arg2) } // RequestAny mocks base method. -func (m *MockNetworkClient) RequestAny(ctx context.Context, minVersion *version.Application, request []byte) (ids.NodeID, []byte, error) { +func (m *MockNetworkClient) RequestAny(arg0 context.Context, arg1 *version.Application, arg2 []byte) (ids.NodeID, []byte, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RequestAny", ctx, minVersion, request) + ret := m.ctrl.Call(m, "RequestAny", arg0, arg1, arg2) ret0, _ := ret[0].(ids.NodeID) ret1, _ := ret[1].([]byte) ret2, _ := ret[2].(error) @@ -118,19 +118,7 @@ func (m *MockNetworkClient) RequestAny(ctx context.Context, minVersion *version. } // RequestAny indicates an expected call of RequestAny. -func (mr *MockNetworkClientMockRecorder) RequestAny(ctx, minVersion, request interface{}) *gomock.Call { +func (mr *MockNetworkClientMockRecorder) RequestAny(arg0, arg1, arg2 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequestAny", reflect.TypeOf((*MockNetworkClient)(nil).RequestAny), ctx, minVersion, request) -} - -// TrackBandwidth mocks base method. -func (m *MockNetworkClient) TrackBandwidth(nodeID ids.NodeID, bandwidth float64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "TrackBandwidth", nodeID, bandwidth) -} - -// TrackBandwidth indicates an expected call of TrackBandwidth. -func (mr *MockNetworkClientMockRecorder) TrackBandwidth(nodeID, bandwidth interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TrackBandwidth", reflect.TypeOf((*MockNetworkClient)(nil).TrackBandwidth), nodeID, bandwidth) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequestAny", reflect.TypeOf((*MockNetworkClient)(nil).RequestAny), arg0, arg1, arg2) }