From f70396c6fdcc26ef89c0fcf9162589e08b94518e Mon Sep 17 00:00:00 2001 From: William Banfield <4561443+williambanfield@users.noreply.github.com> Date: Sat, 17 Jul 2021 20:46:04 -0400 Subject: [PATCH] add and run make target for generating existing mocks (#6732) There are many `//go:generate mockery` lines in the source code. This change adds a make target to invoke these mock generations. This change also invokes the mock invocations and adds the resulting mocks to the repo. Related to #5274 --- Makefile | 13 ++++++++++ abci/client/mocks/client.go | 2 +- internal/p2p/mocks/connection.go | 2 +- internal/p2p/mocks/peer.go | 2 +- internal/p2p/mocks/transport.go | 2 +- light/provider/provider.go | 2 ++ rpc/client/mocks/client.go | 2 +- state/mocks/store.go | 42 -------------------------------- 8 files changed, 20 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index dbc957927..c34f8bf70 100644 --- a/Makefile +++ b/Makefile @@ -231,6 +231,19 @@ build-docker: build-linux rm -rf DOCKER/tendermint .PHONY: build-docker + +############################################################################### +### Testing ### +############################################################################### + +mockery: + go generate -run="mockery" ./... +.PHONY: mockery + +test: + go test ./... +.PHONY: test + ############################################################################### ### Local testnet using docker ### ############################################################################### diff --git a/abci/client/mocks/client.go b/abci/client/mocks/client.go index 0cae177ef..55542753e 100644 --- a/abci/client/mocks/client.go +++ b/abci/client/mocks/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery 2.7.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package mocks diff --git a/internal/p2p/mocks/connection.go b/internal/p2p/mocks/connection.go index ee1f011a0..a0d75502b 100644 --- a/internal/p2p/mocks/connection.go +++ b/internal/p2p/mocks/connection.go @@ -1,4 +1,4 @@ -// Code generated by mockery 2.7.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package mocks diff --git a/internal/p2p/mocks/peer.go b/internal/p2p/mocks/peer.go index d76b5bedb..436542915 100644 --- a/internal/p2p/mocks/peer.go +++ b/internal/p2p/mocks/peer.go @@ -1,4 +1,4 @@ -// Code generated by mockery 2.7.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package mocks diff --git a/internal/p2p/mocks/transport.go b/internal/p2p/mocks/transport.go index 8035e9017..d45cab016 100644 --- a/internal/p2p/mocks/transport.go +++ b/internal/p2p/mocks/transport.go @@ -1,4 +1,4 @@ -// Code generated by mockery 2.7.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package mocks diff --git a/light/provider/provider.go b/light/provider/provider.go index d12b611d0..14b397543 100644 --- a/light/provider/provider.go +++ b/light/provider/provider.go @@ -6,6 +6,8 @@ import ( "github.com/tendermint/tendermint/types" ) +//go:generate mockery --case underscore --name Provider + // Provider provides information for the light client to sync (verification // happens in the client). type Provider interface { diff --git a/rpc/client/mocks/client.go b/rpc/client/mocks/client.go index 9d8d1d2e0..adf1934cd 100644 --- a/rpc/client/mocks/client.go +++ b/rpc/client/mocks/client.go @@ -1,4 +1,4 @@ -// Code generated by mockery 2.7.4. DO NOT EDIT. +// Code generated by mockery v0.0.0-dev. DO NOT EDIT. package mocks diff --git a/state/mocks/store.go b/state/mocks/store.go index bf70adc86..9a693cc98 100644 --- a/state/mocks/store.go +++ b/state/mocks/store.go @@ -95,48 +95,6 @@ func (_m *Store) LoadConsensusParams(_a0 int64) (types.ConsensusParams, error) { return r0, r1 } -// LoadFromDBOrGenesisDoc provides a mock function with given fields: _a0 -func (_m *Store) LoadFromDBOrGenesisDoc(_a0 *types.GenesisDoc) (state.State, error) { - ret := _m.Called(_a0) - - var r0 state.State - if rf, ok := ret.Get(0).(func(*types.GenesisDoc) state.State); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(state.State) - } - - var r1 error - if rf, ok := ret.Get(1).(func(*types.GenesisDoc) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// LoadFromDBOrGenesisFile provides a mock function with given fields: _a0 -func (_m *Store) LoadFromDBOrGenesisFile(_a0 string) (state.State, error) { - ret := _m.Called(_a0) - - var r0 state.State - if rf, ok := ret.Get(0).(func(string) state.State); ok { - r0 = rf(_a0) - } else { - r0 = ret.Get(0).(state.State) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(_a0) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - // LoadValidators provides a mock function with given fields: _a0 func (_m *Store) LoadValidators(_a0 int64) (*types.ValidatorSet, error) { ret := _m.Called(_a0)