Skip to content

Commit

Permalink
refactor(x/evidence): cleanup api (#20103)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Apr 19, 2024
1 parent b2312dd commit d41aa7a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 155 deletions.
65 changes: 14 additions & 51 deletions x/auth/ante/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions x/evidence/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ type KeeperTestSuite struct {
consAddressCodec coreaddress.ConsensusAddressCodec

evidenceKeeper keeper.Keeper
bankKeeper *evidencetestutil.MockBankKeeper
accountKeeper *evidencetestutil.MockAccountKeeper
slashingKeeper *evidencetestutil.MockSlashingKeeper
stakingKeeper *evidencetestutil.MockStakingKeeper
Expand All @@ -103,7 +102,6 @@ func (suite *KeeperTestSuite) SetupTest() {
stakingKeeper := evidencetestutil.NewMockStakingKeeper(ctrl)
slashingKeeper := evidencetestutil.NewMockSlashingKeeper(ctrl)
accountKeeper := evidencetestutil.NewMockAccountKeeper(ctrl)
bankKeeper := evidencetestutil.NewMockBankKeeper(ctrl)

evidenceKeeper := keeper.NewKeeper(
encCfg.Codec,
Expand All @@ -115,7 +113,6 @@ func (suite *KeeperTestSuite) SetupTest() {

suite.stakingKeeper = stakingKeeper
suite.slashingKeeper = slashingKeeper
suite.bankKeeper = bankKeeper

router := types.NewRouter()
router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(evidenceKeeper))
Expand Down
65 changes: 0 additions & 65 deletions x/evidence/testutil/expected_keepers_mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 23 additions & 32 deletions x/evidence/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,28 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

type (
// StakingKeeper defines the staking module interface contract needed by the
// evidence module.
StakingKeeper interface {
ConsensusAddressCodec() address.Codec
ValidatorByConsAddr(context.Context, sdk.ConsAddress) (sdk.ValidatorI, error)
}
// StakingKeeper defines the staking module interface contract needed by the
// evidence module.
type StakingKeeper interface {
ConsensusAddressCodec() address.Codec
ValidatorByConsAddr(context.Context, sdk.ConsAddress) (sdk.ValidatorI, error)
}

// SlashingKeeper defines the slashing module interface contract needed by the
// evidence module.
SlashingKeeper interface {
GetPubkey(context.Context, cryptotypes.Address) (cryptotypes.PubKey, error)
IsTombstoned(context.Context, sdk.ConsAddress) bool
HasValidatorSigningInfo(context.Context, sdk.ConsAddress) bool
Tombstone(context.Context, sdk.ConsAddress) error
Slash(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64) error
SlashWithInfractionReason(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64, st.Infraction) error
SlashFractionDoubleSign(context.Context) (math.LegacyDec, error)
Jail(context.Context, sdk.ConsAddress) error
JailUntil(context.Context, sdk.ConsAddress, time.Time) error
}
// SlashingKeeper defines the slashing module interface contract needed by the
// evidence module.
type SlashingKeeper interface {
GetPubkey(context.Context, cryptotypes.Address) (cryptotypes.PubKey, error)
IsTombstoned(context.Context, sdk.ConsAddress) bool
HasValidatorSigningInfo(context.Context, sdk.ConsAddress) bool
Tombstone(context.Context, sdk.ConsAddress) error
Slash(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64) error
SlashWithInfractionReason(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64, st.Infraction) error
SlashFractionDoubleSign(context.Context) (math.LegacyDec, error)
Jail(context.Context, sdk.ConsAddress) error
JailUntil(context.Context, sdk.ConsAddress, time.Time) error
}

// AccountKeeper define the account keeper interface contracted needed by the evidence module
AccountKeeper interface {
SetAccount(ctx context.Context, acc sdk.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
}
)
// AccountKeeper define the account keeper interface contracted needed by the evidence module
type AccountKeeper interface {
SetAccount(ctx context.Context, acc sdk.AccountI)
}
7 changes: 3 additions & 4 deletions x/feegrant/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func WeightedOperations(
),
simulation.NewWeightedOperation(
weightMsgRevokeAllowance,
SimulateMsgRevokeAllowance(pCdc, txConfig, ak, bk, k, ac),
SimulateMsgRevokeAllowance(pCdc, txConfig, ak, bk, k),
),
}
}
Expand Down Expand Up @@ -141,7 +141,6 @@ func SimulateMsgRevokeAllowance(
ak feegrant.AccountKeeper,
bk feegrant.BankKeeper,
k keeper.Keeper,
ac address.Codec,
) simtypes.Operation {
return func(
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
Expand All @@ -151,11 +150,11 @@ func SimulateMsgRevokeAllowance(
var granterAddr sdk.AccAddress
var granteeAddr sdk.AccAddress
err := k.IterateAllFeeAllowances(ctx, func(grant feegrant.Grant) bool {
granter, err := ac.StringToBytes(grant.Granter)
granter, err := ak.AddressCodec().StringToBytes(grant.Granter)
if err != nil {
panic(err)
}
grantee, err := ac.StringToBytes(grant.Grantee)
grantee, err := ak.AddressCodec().StringToBytes(grant.Grantee)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit d41aa7a

Please sign in to comment.