Skip to content

Commit d41aa7a

Browse files
authored
refactor(x/evidence): cleanup api (#20103)
1 parent b2312dd commit d41aa7a

File tree

5 files changed

+40
-155
lines changed

5 files changed

+40
-155
lines changed

x/auth/ante/testutil/expected_keepers_mocks.go

Lines changed: 14 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/evidence/keeper/keeper_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ type KeeperTestSuite struct {
7979
consAddressCodec coreaddress.ConsensusAddressCodec
8080

8181
evidenceKeeper keeper.Keeper
82-
bankKeeper *evidencetestutil.MockBankKeeper
8382
accountKeeper *evidencetestutil.MockAccountKeeper
8483
slashingKeeper *evidencetestutil.MockSlashingKeeper
8584
stakingKeeper *evidencetestutil.MockStakingKeeper
@@ -103,7 +102,6 @@ func (suite *KeeperTestSuite) SetupTest() {
103102
stakingKeeper := evidencetestutil.NewMockStakingKeeper(ctrl)
104103
slashingKeeper := evidencetestutil.NewMockSlashingKeeper(ctrl)
105104
accountKeeper := evidencetestutil.NewMockAccountKeeper(ctrl)
106-
bankKeeper := evidencetestutil.NewMockBankKeeper(ctrl)
107105

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

116114
suite.stakingKeeper = stakingKeeper
117115
suite.slashingKeeper = slashingKeeper
118-
suite.bankKeeper = bankKeeper
119116

120117
router := types.NewRouter()
121118
router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(evidenceKeeper))

x/evidence/testutil/expected_keepers_mocks.go

Lines changed: 0 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/evidence/types/expected_keepers.go

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,28 @@ import (
1212
sdk "github.com/cosmos/cosmos-sdk/types"
1313
)
1414

15-
type (
16-
// StakingKeeper defines the staking module interface contract needed by the
17-
// evidence module.
18-
StakingKeeper interface {
19-
ConsensusAddressCodec() address.Codec
20-
ValidatorByConsAddr(context.Context, sdk.ConsAddress) (sdk.ValidatorI, error)
21-
}
15+
// StakingKeeper defines the staking module interface contract needed by the
16+
// evidence module.
17+
type StakingKeeper interface {
18+
ConsensusAddressCodec() address.Codec
19+
ValidatorByConsAddr(context.Context, sdk.ConsAddress) (sdk.ValidatorI, error)
20+
}
2221

23-
// SlashingKeeper defines the slashing module interface contract needed by the
24-
// evidence module.
25-
SlashingKeeper interface {
26-
GetPubkey(context.Context, cryptotypes.Address) (cryptotypes.PubKey, error)
27-
IsTombstoned(context.Context, sdk.ConsAddress) bool
28-
HasValidatorSigningInfo(context.Context, sdk.ConsAddress) bool
29-
Tombstone(context.Context, sdk.ConsAddress) error
30-
Slash(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64) error
31-
SlashWithInfractionReason(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64, st.Infraction) error
32-
SlashFractionDoubleSign(context.Context) (math.LegacyDec, error)
33-
Jail(context.Context, sdk.ConsAddress) error
34-
JailUntil(context.Context, sdk.ConsAddress, time.Time) error
35-
}
22+
// SlashingKeeper defines the slashing module interface contract needed by the
23+
// evidence module.
24+
type SlashingKeeper interface {
25+
GetPubkey(context.Context, cryptotypes.Address) (cryptotypes.PubKey, error)
26+
IsTombstoned(context.Context, sdk.ConsAddress) bool
27+
HasValidatorSigningInfo(context.Context, sdk.ConsAddress) bool
28+
Tombstone(context.Context, sdk.ConsAddress) error
29+
Slash(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64) error
30+
SlashWithInfractionReason(context.Context, sdk.ConsAddress, math.LegacyDec, int64, int64, st.Infraction) error
31+
SlashFractionDoubleSign(context.Context) (math.LegacyDec, error)
32+
Jail(context.Context, sdk.ConsAddress) error
33+
JailUntil(context.Context, sdk.ConsAddress, time.Time) error
34+
}
3635

37-
// AccountKeeper define the account keeper interface contracted needed by the evidence module
38-
AccountKeeper interface {
39-
SetAccount(ctx context.Context, acc sdk.AccountI)
40-
}
41-
42-
// BankKeeper define the account keeper interface contracted needed by the evidence module
43-
BankKeeper interface {
44-
MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
45-
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
46-
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
47-
}
48-
)
36+
// AccountKeeper define the account keeper interface contracted needed by the evidence module
37+
type AccountKeeper interface {
38+
SetAccount(ctx context.Context, acc sdk.AccountI)
39+
}

x/feegrant/simulation/operations.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func WeightedOperations(
6565
),
6666
simulation.NewWeightedOperation(
6767
weightMsgRevokeAllowance,
68-
SimulateMsgRevokeAllowance(pCdc, txConfig, ak, bk, k, ac),
68+
SimulateMsgRevokeAllowance(pCdc, txConfig, ak, bk, k),
6969
),
7070
}
7171
}
@@ -141,7 +141,6 @@ func SimulateMsgRevokeAllowance(
141141
ak feegrant.AccountKeeper,
142142
bk feegrant.BankKeeper,
143143
k keeper.Keeper,
144-
ac address.Codec,
145144
) simtypes.Operation {
146145
return func(
147146
r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
@@ -151,11 +150,11 @@ func SimulateMsgRevokeAllowance(
151150
var granterAddr sdk.AccAddress
152151
var granteeAddr sdk.AccAddress
153152
err := k.IterateAllFeeAllowances(ctx, func(grant feegrant.Grant) bool {
154-
granter, err := ac.StringToBytes(grant.Granter)
153+
granter, err := ak.AddressCodec().StringToBytes(grant.Granter)
155154
if err != nil {
156155
panic(err)
157156
}
158-
grantee, err := ac.StringToBytes(grant.Grantee)
157+
grantee, err := ak.AddressCodec().StringToBytes(grant.Grantee)
159158
if err != nil {
160159
panic(err)
161160
}

0 commit comments

Comments
 (0)