From cc5fe49ce7e2b519cf9126544107b3f27b98de9a Mon Sep 17 00:00:00 2001 From: Jeancarlo Barrios Date: Mon, 1 Aug 2022 11:16:38 -0600 Subject: [PATCH] refactor: migrate x/evidence to mocks (#12749) ## Description Closes: #12501 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- scripts/mockgen.sh | 3 +- x/evidence/keeper/grpc_query_test.go | 2 +- x/evidence/keeper/infraction_test.go | 72 ++++- x/evidence/keeper/keeper_test.go | 94 +++--- x/evidence/testutil/expected_keepers_mocks.go | 295 ++++++++++++++++++ x/evidence/types/expected_keepers.go | 14 + 6 files changed, 420 insertions(+), 60 deletions(-) create mode 100644 x/evidence/testutil/expected_keepers_mocks.go diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh index f2c03d0f7d..2c0fcc42e8 100755 --- a/scripts/mockgen.sh +++ b/scripts/mockgen.sh @@ -17,4 +17,5 @@ $mockgen_cmd -source=x/params/proposal_handler_test.go -package testutil -destin $mockgen_cmd -source=x/crisis/types/expected_keepers.go -package testutil -destination x/crisis/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/auth/types/expected_keepers.go -package testutil -destination x/auth/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/auth/ante/expected_keepers.go -package testutil -destination x/auth/ante/testutil/expected_keepers_mocks.go -$mockgen_cmd -source=x/bank/types/expected_keepers.go -package testutil -destination x/bank/testutil/expected_keepers_mocks.go \ No newline at end of file +$mockgen_cmd -source=x/bank/types/expected_keepers.go -package testutil -destination x/bank/testutil/expected_keepers_mocks.go +$mockgen_cmd -source=x/evidence/types/expected_keepers.go -package testutil -destination x/evidence/testutil/expected_keepers_mocks.go diff --git a/x/evidence/keeper/grpc_query_test.go b/x/evidence/keeper/grpc_query_test.go index 80f2ded86b..0fb87bbfca 100644 --- a/x/evidence/keeper/grpc_query_test.go +++ b/x/evidence/keeper/grpc_query_test.go @@ -49,7 +49,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence() { true, func(res *types.QueryEvidenceResponse) { var evi exported.Evidence - err := suite.interfaceRegistry.UnpackAny(res.Evidence, &evi) + err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Evidence, &evi) suite.Require().NoError(err) suite.Require().NotNil(evi) suite.Require().Equal(evi, evidence[0]) diff --git a/x/evidence/keeper/infraction_test.go b/x/evidence/keeper/infraction_test.go index 226e67ba57..ad9bf8bf88 100644 --- a/x/evidence/keeper/infraction_test.go +++ b/x/evidence/keeper/infraction_test.go @@ -1,15 +1,68 @@ package keeper_test import ( - "time" - + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/runtime" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/cosmos/cosmos-sdk/x/evidence/keeper" + "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/cosmos/cosmos-sdk/x/evidence/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" "github.com/cosmos/cosmos-sdk/x/staking" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/teststaking" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "time" ) -func (suite *KeeperTestSuite) TestHandleDoubleSign() { +type InfractionTestSuite struct { + suite.Suite + + ctx sdk.Context + app *runtime.App + + evidenceKeeper keeper.Keeper + bankKeeper bankkeeper.Keeper + accountKeeper authkeeper.AccountKeeper + slashingKeeper slashingkeeper.Keeper + stakingKeeper *stakingkeeper.Keeper + interfaceRegistry codectypes.InterfaceRegistry + + queryClient types.QueryClient +} + +func (suite *InfractionTestSuite) SetupTest() { + var ( + evidenceKeeper keeper.Keeper + ) + + app, err := simtestutil.Setup(testutil.AppConfig, + &evidenceKeeper, + &suite.interfaceRegistry, + &suite.accountKeeper, + &suite.bankKeeper, + &suite.slashingKeeper, + &suite.stakingKeeper, + ) + require.NoError(suite.T(), err) + + router := types.NewRouter() + router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(evidenceKeeper)) + evidenceKeeper.SetRouter(router) + + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) + suite.app = app + + suite.evidenceKeeper = evidenceKeeper +} + +func (suite *InfractionTestSuite) TestHandleDoubleSign() { ctx := suite.ctx.WithIsCheckTx(false).WithBlockHeight(1) suite.populateValidators(ctx) @@ -75,7 +128,7 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign() { suite.Len(evidences, 1) } -func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() { +func (suite *InfractionTestSuite) TestHandleDoubleSign_TooOld() { ctx := suite.ctx.WithIsCheckTx(false).WithBlockHeight(1).WithBlockTime(time.Now()) suite.populateValidators(ctx) @@ -111,3 +164,14 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() { suite.False(suite.stakingKeeper.Validator(ctx, operatorAddr).IsJailed()) suite.False(suite.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address()))) } + +func (suite *InfractionTestSuite) populateValidators(ctx sdk.Context) { + // add accounts and set total supply + totalSupplyAmt := initAmt.MulRaw(int64(len(valAddresses))) + totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupplyAmt)) + suite.NoError(suite.bankKeeper.MintCoins(ctx, minttypes.ModuleName, totalSupply)) + + for _, addr := range valAddresses { + suite.NoError(suite.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, (sdk.AccAddress)(addr), initCoins)) + } +} diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index aac0825a28..3d3bddefa5 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -3,29 +3,22 @@ package keeper_test import ( "encoding/hex" "fmt" + "github.com/cosmos/cosmos-sdk/testutil" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/evidence" + evidencetestutil "github.com/cosmos/cosmos-sdk/x/evidence/testutil" + "github.com/golang/mock/gomock" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "time" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/keeper" - "github.com/cosmos/cosmos-sdk/x/evidence/testutil" "github.com/cosmos/cosmos-sdk/x/evidence/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/stretchr/testify/suite" ) var ( @@ -80,49 +73,53 @@ type KeeperTestSuite struct { ctx sdk.Context querier sdk.Querier - app *runtime.App - evidenceKeeper keeper.Keeper - bankKeeper bankkeeper.Keeper - accountKeeper authkeeper.AccountKeeper - slashingKeeper slashingkeeper.Keeper - stakingKeeper *stakingkeeper.Keeper - interfaceRegistry codectypes.InterfaceRegistry - - queryClient types.QueryClient + evidenceKeeper keeper.Keeper + bankKeeper *evidencetestutil.MockBankKeeper + accountKeeper *evidencetestutil.MockAccountKeeper + slashingKeeper *evidencetestutil.MockSlashingKeeper + stakingKeeper *evidencetestutil.MockStakingKeeper + queryClient types.QueryClient + encCfg moduletestutil.TestEncodingConfig } func (suite *KeeperTestSuite) SetupTest() { - var ( - evidenceKeeper keeper.Keeper + encCfg := moduletestutil.MakeTestEncodingConfig(evidence.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + tkey := sdk.NewTransientStoreKey("evidence_transient_store") + testCtx := testutil.DefaultContext(key, tkey) + suite.ctx = testCtx + + ctrl := gomock.NewController(suite.T()) + + stakingKeeper := evidencetestutil.NewMockStakingKeeper(ctrl) + slashingKeeper := evidencetestutil.NewMockSlashingKeeper(ctrl) + accountKeeper := evidencetestutil.NewMockAccountKeeper(ctrl) + bankKeeper := evidencetestutil.NewMockBankKeeper(ctrl) + + evidenceKeeper := keeper.NewKeeper( + encCfg.Codec, + key, + stakingKeeper, + slashingKeeper, ) - app, err := simtestutil.Setup(testutil.AppConfig, - &evidenceKeeper, - &suite.interfaceRegistry, - &suite.accountKeeper, - &suite.bankKeeper, - &suite.slashingKeeper, - &suite.stakingKeeper, - ) - require.NoError(suite.T(), err) + suite.stakingKeeper = stakingKeeper + suite.slashingKeeper = slashingKeeper + suite.bankKeeper = bankKeeper router := types.NewRouter() router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(evidenceKeeper)) evidenceKeeper.SetRouter(router) + suite.ctx = testCtx.WithBlockHeader(tmproto.Header{Height: 1}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(evidence.AppModuleBasic{}) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) - suite.app = app + suite.accountKeeper = accountKeeper - for i, addr := range valAddresses { - addr := sdk.AccAddress(addr) - suite.accountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], uint64(i), 0)) - } - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.interfaceRegistry) + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.encCfg.InterfaceRegistry) types.RegisterQueryServer(queryHelper, evidenceKeeper) suite.queryClient = types.NewQueryClient(queryHelper) - suite.evidenceKeeper = evidenceKeeper + suite.evidenceKeeper = *evidenceKeeper } func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) []exported.Evidence { @@ -144,17 +141,6 @@ func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int) return evidence } -func (suite *KeeperTestSuite) populateValidators(ctx sdk.Context) { - // add accounts and set total supply - totalSupplyAmt := initAmt.MulRaw(int64(len(valAddresses))) - totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupplyAmt)) - suite.NoError(suite.bankKeeper.MintCoins(ctx, minttypes.ModuleName, totalSupply)) - - for _, addr := range valAddresses { - suite.NoError(suite.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, (sdk.AccAddress)(addr), initCoins)) - } -} - func (suite *KeeperTestSuite) TestSubmitValidEvidence() { ctx := suite.ctx.WithIsCheckTx(false) pk := ed25519.GenPrivKey() diff --git a/x/evidence/testutil/expected_keepers_mocks.go b/x/evidence/testutil/expected_keepers_mocks.go new file mode 100644 index 0000000000..7222ecf3f4 --- /dev/null +++ b/x/evidence/testutil/expected_keepers_mocks.go @@ -0,0 +1,295 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/evidence/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + time "time" + + types "github.com/cosmos/cosmos-sdk/crypto/types" + types0 "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/x/auth/types" + types2 "github.com/cosmos/cosmos-sdk/x/staking/types" + gomock "github.com/golang/mock/gomock" +) + +// MockStakingKeeper is a mock of StakingKeeper interface. +type MockStakingKeeper struct { + ctrl *gomock.Controller + recorder *MockStakingKeeperMockRecorder +} + +// MockStakingKeeperMockRecorder is the mock recorder for MockStakingKeeper. +type MockStakingKeeperMockRecorder struct { + mock *MockStakingKeeper +} + +// NewMockStakingKeeper creates a new mock instance. +func NewMockStakingKeeper(ctrl *gomock.Controller) *MockStakingKeeper { + mock := &MockStakingKeeper{ctrl: ctrl} + mock.recorder = &MockStakingKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockStakingKeeper) EXPECT() *MockStakingKeeperMockRecorder { + return m.recorder +} + +// GetParams mocks base method. +func (m *MockStakingKeeper) GetParams(ctx types0.Context) types2.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetParams", ctx) + ret0, _ := ret[0].(types2.Params) + return ret0 +} + +// GetParams indicates an expected call of GetParams. +func (mr *MockStakingKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockStakingKeeper)(nil).GetParams), ctx) +} + +// ValidatorByConsAddr mocks base method. +func (m *MockStakingKeeper) ValidatorByConsAddr(arg0 types0.Context, arg1 types0.ConsAddress) types2.ValidatorI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ValidatorByConsAddr", arg0, arg1) + ret0, _ := ret[0].(types2.ValidatorI) + return ret0 +} + +// ValidatorByConsAddr indicates an expected call of ValidatorByConsAddr. +func (mr *MockStakingKeeperMockRecorder) ValidatorByConsAddr(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatorByConsAddr", reflect.TypeOf((*MockStakingKeeper)(nil).ValidatorByConsAddr), arg0, arg1) +} + +// MockSlashingKeeper is a mock of SlashingKeeper interface. +type MockSlashingKeeper struct { + ctrl *gomock.Controller + recorder *MockSlashingKeeperMockRecorder +} + +// MockSlashingKeeperMockRecorder is the mock recorder for MockSlashingKeeper. +type MockSlashingKeeperMockRecorder struct { + mock *MockSlashingKeeper +} + +// NewMockSlashingKeeper creates a new mock instance. +func NewMockSlashingKeeper(ctrl *gomock.Controller) *MockSlashingKeeper { + mock := &MockSlashingKeeper{ctrl: ctrl} + mock.recorder = &MockSlashingKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockSlashingKeeper) EXPECT() *MockSlashingKeeperMockRecorder { + return m.recorder +} + +// GetPubkey mocks base method. +func (m *MockSlashingKeeper) GetPubkey(arg0 types0.Context, arg1 types.Address) (types.PubKey, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetPubkey", arg0, arg1) + ret0, _ := ret[0].(types.PubKey) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetPubkey indicates an expected call of GetPubkey. +func (mr *MockSlashingKeeperMockRecorder) GetPubkey(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPubkey", reflect.TypeOf((*MockSlashingKeeper)(nil).GetPubkey), arg0, arg1) +} + +// HasValidatorSigningInfo mocks base method. +func (m *MockSlashingKeeper) HasValidatorSigningInfo(arg0 types0.Context, arg1 types0.ConsAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasValidatorSigningInfo", arg0, arg1) + ret0, _ := ret[0].(bool) + return ret0 +} + +// HasValidatorSigningInfo indicates an expected call of HasValidatorSigningInfo. +func (mr *MockSlashingKeeperMockRecorder) HasValidatorSigningInfo(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasValidatorSigningInfo", reflect.TypeOf((*MockSlashingKeeper)(nil).HasValidatorSigningInfo), arg0, arg1) +} + +// IsTombstoned mocks base method. +func (m *MockSlashingKeeper) IsTombstoned(arg0 types0.Context, arg1 types0.ConsAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsTombstoned", arg0, arg1) + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsTombstoned indicates an expected call of IsTombstoned. +func (mr *MockSlashingKeeperMockRecorder) IsTombstoned(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsTombstoned", reflect.TypeOf((*MockSlashingKeeper)(nil).IsTombstoned), arg0, arg1) +} + +// Jail mocks base method. +func (m *MockSlashingKeeper) Jail(arg0 types0.Context, arg1 types0.ConsAddress) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Jail", arg0, arg1) +} + +// Jail indicates an expected call of Jail. +func (mr *MockSlashingKeeperMockRecorder) Jail(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Jail", reflect.TypeOf((*MockSlashingKeeper)(nil).Jail), arg0, arg1) +} + +// JailUntil mocks base method. +func (m *MockSlashingKeeper) JailUntil(arg0 types0.Context, arg1 types0.ConsAddress, arg2 time.Time) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "JailUntil", arg0, arg1, arg2) +} + +// JailUntil indicates an expected call of JailUntil. +func (mr *MockSlashingKeeperMockRecorder) JailUntil(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "JailUntil", reflect.TypeOf((*MockSlashingKeeper)(nil).JailUntil), arg0, arg1, arg2) +} + +// Slash mocks base method. +func (m *MockSlashingKeeper) Slash(arg0 types0.Context, arg1 types0.ConsAddress, arg2 types0.Dec, arg3, arg4 int64) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Slash", arg0, arg1, arg2, arg3, arg4) +} + +// Slash indicates an expected call of Slash. +func (mr *MockSlashingKeeperMockRecorder) Slash(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Slash", reflect.TypeOf((*MockSlashingKeeper)(nil).Slash), arg0, arg1, arg2, arg3, arg4) +} + +// SlashFractionDoubleSign mocks base method. +func (m *MockSlashingKeeper) SlashFractionDoubleSign(arg0 types0.Context) types0.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SlashFractionDoubleSign", arg0) + ret0, _ := ret[0].(types0.Dec) + return ret0 +} + +// SlashFractionDoubleSign indicates an expected call of SlashFractionDoubleSign. +func (mr *MockSlashingKeeperMockRecorder) SlashFractionDoubleSign(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SlashFractionDoubleSign", reflect.TypeOf((*MockSlashingKeeper)(nil).SlashFractionDoubleSign), arg0) +} + +// Tombstone mocks base method. +func (m *MockSlashingKeeper) Tombstone(arg0 types0.Context, arg1 types0.ConsAddress) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Tombstone", arg0, arg1) +} + +// Tombstone indicates an expected call of Tombstone. +func (mr *MockSlashingKeeperMockRecorder) Tombstone(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Tombstone", reflect.TypeOf((*MockSlashingKeeper)(nil).Tombstone), arg0, arg1) +} + +// MockAccountKeeper is a mock of AccountKeeper interface. +type MockAccountKeeper struct { + ctrl *gomock.Controller + recorder *MockAccountKeeperMockRecorder +} + +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. +type MockAccountKeeperMockRecorder struct { + mock *MockAccountKeeper +} + +// NewMockAccountKeeper creates a new mock instance. +func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { + mock := &MockAccountKeeper{ctrl: ctrl} + mock.recorder = &MockAccountKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { + return m.recorder +} + +// SetAccount mocks base method. +func (m *MockAccountKeeper) SetAccount(ctx types0.Context, acc types1.AccountI) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetAccount", ctx, acc) +} + +// SetAccount indicates an expected call of SetAccount. +func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc) +} + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// GetAllBalances mocks base method. +func (m *MockBankKeeper) GetAllBalances(ctx types0.Context, addr types0.AccAddress) types0.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) + ret0, _ := ret[0].(types0.Coins) + return ret0 +} + +// GetAllBalances indicates an expected call of GetAllBalances. +func (mr *MockBankKeeperMockRecorder) GetAllBalances(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBalances", reflect.TypeOf((*MockBankKeeper)(nil).GetAllBalances), ctx, addr) +} + +// MintCoins mocks base method. +func (m *MockBankKeeper) MintCoins(ctx types0.Context, moduleName string, amt types0.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "MintCoins", ctx, moduleName, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// MintCoins indicates an expected call of MintCoins. +func (mr *MockBankKeeperMockRecorder) MintCoins(ctx, moduleName, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MintCoins", reflect.TypeOf((*MockBankKeeper)(nil).MintCoins), ctx, moduleName, amt) +} + +// SendCoinsFromModuleToAccount mocks base method. +func (m *MockBankKeeper) SendCoinsFromModuleToAccount(ctx types0.Context, senderModule string, recipientAddr types0.AccAddress, amt types0.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromModuleToAccount", ctx, senderModule, recipientAddr, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromModuleToAccount indicates an expected call of SendCoinsFromModuleToAccount. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromModuleToAccount(ctx, senderModule, recipientAddr, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromModuleToAccount", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromModuleToAccount), ctx, senderModule, recipientAddr, amt) +} diff --git a/x/evidence/types/expected_keepers.go b/x/evidence/types/expected_keepers.go index 0f1d87774c..93e1ef72db 100644 --- a/x/evidence/types/expected_keepers.go +++ b/x/evidence/types/expected_keepers.go @@ -1,6 +1,7 @@ package types import ( + "github.com/cosmos/cosmos-sdk/x/auth/types" "time" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -13,6 +14,7 @@ type ( // evidence module. StakingKeeper interface { ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI + GetParams(ctx sdk.Context) (params stakingtypes.Params) } // SlashingKeeper defines the slashing module interface contract needed by the @@ -27,4 +29,16 @@ type ( Jail(sdk.Context, sdk.ConsAddress) JailUntil(sdk.Context, sdk.ConsAddress, time.Time) } + + // AccountKeeper define the account keeper interface contracted needed by the evidence module + AccountKeeper interface { + SetAccount(ctx sdk.Context, acc types.AccountI) + } + + // BankKeeper define the account keeper interface contracted needed by the evidence module + BankKeeper interface { + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + } )