Skip to content

Commit 9f7a160

Browse files
mergify[bot]facundomedicajulienrbrt
authored
refactor(x/staking)!: KVStoreService, return errors and use context.Context (backport #16324) (#16598)
Co-authored-by: Facundo Medica <[email protected]> Co-authored-by: Julien Robert <[email protected]> Co-authored-by: Facundo Medica <[email protected]>
1 parent c06d8d7 commit 9f7a160

File tree

115 files changed

+3596
-2227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+3596
-2227
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
4747

4848
* (x/auth) [#16554](https://github.com/cosmos/cosmos-sdk/pull/16554) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking.
4949

50+
### API Breaking Changes
51+
52+
* (x/staking) [#16324](https://github.com/cosmos/cosmos-sdk/pull/16324) `NewKeeper` now takes a `KVStoreService` instead of a `StoreKey`, and methods in the `Keeper` now take a `context.Context` instead of a `sdk.Context` and return an `error`. Notable changes:
53+
* `Validator` method now returns `types.ErrNoValidatorFound` instead of `nil` when not found.
54+
5055
## [v0.50.0-alpha.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.0-alpha.0) - 2023-06-07
5156

5257
### Features

simapp/app.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func NewSimApp(
321321
logger,
322322
)
323323
app.StakingKeeper = stakingkeeper.NewKeeper(
324-
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
324+
appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
325325
)
326326
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
327327

simapp/export.go

+20-7
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
7777
/* Handle fee distribution state. */
7878

7979
// withdraw all validator commission
80-
app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
80+
err := app.StakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) {
8181
_, _ = app.DistrKeeper.WithdrawValidatorCommission(ctx, val.GetOperator())
8282
return false
8383
})
84+
if err != nil {
85+
panic(err)
86+
}
8487

8588
// withdraw all delegator rewards
86-
dels := app.StakingKeeper.GetAllDelegations(ctx)
89+
dels, err := app.StakingKeeper.GetAllDelegations(ctx)
90+
if err != nil {
91+
panic(err)
92+
}
93+
8794
for _, delegation := range dels {
8895
valAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
8996
if err != nil {
@@ -156,7 +163,10 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
156163
for i := range red.Entries {
157164
red.Entries[i].CreationHeight = 0
158165
}
159-
app.StakingKeeper.SetRedelegation(ctx, red)
166+
err = app.StakingKeeper.SetRedelegation(ctx, red)
167+
if err != nil {
168+
panic(err)
169+
}
160170
return false
161171
})
162172

@@ -165,7 +175,10 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
165175
for i := range ubd.Entries {
166176
ubd.Entries[i].CreationHeight = 0
167177
}
168-
app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
178+
err = app.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
179+
if err != nil {
180+
panic(err)
181+
}
169182
return false
170183
})
171184

@@ -177,8 +190,8 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
177190

178191
for ; iter.Valid(); iter.Next() {
179192
addr := sdk.ValAddress(stakingtypes.AddressFromValidatorsKey(iter.Key()))
180-
validator, found := app.StakingKeeper.GetValidator(ctx, addr)
181-
if !found {
193+
validator, err := app.StakingKeeper.GetValidator(ctx, addr)
194+
if err != nil {
182195
panic("expected validator, not found")
183196
}
184197

@@ -196,7 +209,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []
196209
return
197210
}
198211

199-
_, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
212+
_, err = app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx)
200213
if err != nil {
201214
log.Fatal(err)
202215
}

simapp/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
cosmossdk.io/tools/confix v0.0.0-20230614114324-f368ed5c62bc
1414
cosmossdk.io/tools/rosetta v0.2.1-0.20230614114324-f368ed5c62bc
1515
cosmossdk.io/x/circuit v0.0.0-20230614114324-f368ed5c62bc
16-
cosmossdk.io/x/evidence v0.0.0-20230614114324-f368ed5c62bc
16+
cosmossdk.io/x/evidence v0.0.0-20230616204757-46e5f3fb0376
1717
cosmossdk.io/x/feegrant v0.0.0-20230614114324-f368ed5c62bc
1818
cosmossdk.io/x/nft v0.0.0-20230614114324-f368ed5c62bc
1919
cosmossdk.io/x/tx v0.8.0

simapp/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ cosmossdk.io/tools/rosetta v0.2.1-0.20230614114324-f368ed5c62bc h1:7gFe3tRGqaA3s
212212
cosmossdk.io/tools/rosetta v0.2.1-0.20230614114324-f368ed5c62bc/go.mod h1:l5qTTiHcPXf1m3iz7WuACKFmHW2ewAuIW/+ZcWcUm4Q=
213213
cosmossdk.io/x/circuit v0.0.0-20230614114324-f368ed5c62bc h1:JwM4NDnE5nBZeLllLKPoftFtq0eztBWE0vlc3GDxmlk=
214214
cosmossdk.io/x/circuit v0.0.0-20230614114324-f368ed5c62bc/go.mod h1:VcyU4WzhBXJr+XAAFyGMuR4/CjZLVYtj5EYIH4UwFv4=
215-
cosmossdk.io/x/evidence v0.0.0-20230614114324-f368ed5c62bc h1:M75vwNysEwbig9+GrY62hc2E1dEt7hfRwBsFVofGDkQ=
216-
cosmossdk.io/x/evidence v0.0.0-20230614114324-f368ed5c62bc/go.mod h1:p6buH/50prKzlsCO4Wixv9rizvg4WRCatv/MqqcxoWI=
215+
cosmossdk.io/x/evidence v0.0.0-20230616204757-46e5f3fb0376 h1:6dgsdUP4yHokKLE99qZUT6i4BtYEuMSW2Of0ufYKyNE=
216+
cosmossdk.io/x/evidence v0.0.0-20230616204757-46e5f3fb0376/go.mod h1:p6buH/50prKzlsCO4Wixv9rizvg4WRCatv/MqqcxoWI=
217217
cosmossdk.io/x/feegrant v0.0.0-20230614114324-f368ed5c62bc h1:Ycesi/NLYXvHrxrWee9PF46Rmek38B7M4UP9MMzCptk=
218218
cosmossdk.io/x/feegrant v0.0.0-20230614114324-f368ed5c62bc/go.mod h1:OUQndoNT6o5MAtRBF9eCQx22nBVO+gHdyKYOcK6dAVo=
219219
cosmossdk.io/x/nft v0.0.0-20230614114324-f368ed5c62bc h1:jSfbIQybYPjsHEoqxefBsS9kW+R9t2nmu4bsjeE2wGI=

simapp/test_helpers.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,12 @@ func AddTestAddrsIncremental(app *SimApp, ctx sdk.Context, accNum int, accAmt sd
190190

191191
func addTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdkmath.Int, strategy simtestutil.GenerateAccountStrategy) []sdk.AccAddress {
192192
testAddrs := strategy(accNum)
193+
bondDenom, err := app.StakingKeeper.BondDenom(ctx)
194+
if err != nil {
195+
panic(err)
196+
}
193197

194-
initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt))
198+
initCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, accAmt))
195199

196200
for _, addr := range testAddrs {
197201
initAccountWithCoins(app, ctx, addr, initCoins)

tests/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
cosmossdk.io/math v1.0.1
1313
cosmossdk.io/simapp v0.0.0-20230309163709-87da587416ba
1414
cosmossdk.io/store v0.1.0-alpha.1.0.20230606190835-3e18f4088b2c
15-
cosmossdk.io/x/evidence v0.0.0-20230614114324-f368ed5c62bc
15+
cosmossdk.io/x/evidence v0.0.0-20230616204757-46e5f3fb0376
1616
cosmossdk.io/x/feegrant v0.0.0-20230614114324-f368ed5c62bc
1717
cosmossdk.io/x/nft v0.0.0-20230614114324-f368ed5c62bc // indirect
1818
cosmossdk.io/x/tx v0.8.0

tests/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ cosmossdk.io/store v0.1.0-alpha.1.0.20230606190835-3e18f4088b2c h1:A+FMPW9GtfcPB
208208
cosmossdk.io/store v0.1.0-alpha.1.0.20230606190835-3e18f4088b2c/go.mod h1:RbYGvXCbz8uNBCXrwS9Z8SyydeWi+W5x5MZ33muyzMw=
209209
cosmossdk.io/x/circuit v0.0.0-20230614114324-f368ed5c62bc h1:JwM4NDnE5nBZeLllLKPoftFtq0eztBWE0vlc3GDxmlk=
210210
cosmossdk.io/x/circuit v0.0.0-20230614114324-f368ed5c62bc/go.mod h1:VcyU4WzhBXJr+XAAFyGMuR4/CjZLVYtj5EYIH4UwFv4=
211-
cosmossdk.io/x/evidence v0.0.0-20230614114324-f368ed5c62bc h1:M75vwNysEwbig9+GrY62hc2E1dEt7hfRwBsFVofGDkQ=
212-
cosmossdk.io/x/evidence v0.0.0-20230614114324-f368ed5c62bc/go.mod h1:p6buH/50prKzlsCO4Wixv9rizvg4WRCatv/MqqcxoWI=
211+
cosmossdk.io/x/evidence v0.0.0-20230616204757-46e5f3fb0376 h1:6dgsdUP4yHokKLE99qZUT6i4BtYEuMSW2Of0ufYKyNE=
212+
cosmossdk.io/x/evidence v0.0.0-20230616204757-46e5f3fb0376/go.mod h1:p6buH/50prKzlsCO4Wixv9rizvg4WRCatv/MqqcxoWI=
213213
cosmossdk.io/x/feegrant v0.0.0-20230614114324-f368ed5c62bc h1:Ycesi/NLYXvHrxrWee9PF46Rmek38B7M4UP9MMzCptk=
214214
cosmossdk.io/x/feegrant v0.0.0-20230614114324-f368ed5c62bc/go.mod h1:OUQndoNT6o5MAtRBF9eCQx22nBVO+gHdyKYOcK6dAVo=
215215
cosmossdk.io/x/nft v0.0.0-20230614114324-f368ed5c62bc h1:jSfbIQybYPjsHEoqxefBsS9kW+R9t2nmu4bsjeE2wGI=

tests/integration/distribution/keeper/msg_server_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func initFixture(t testing.TB) *fixture {
9595
log.NewNopLogger(),
9696
)
9797

98-
stakingKeeper := stakingkeeper.NewKeeper(cdc, keys[stakingtypes.StoreKey], accountKeeper, bankKeeper, authority.String())
98+
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String())
9999

100100
distrKeeper := distrkeeper.NewKeeper(
101101
cdc, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), accountKeeper, bankKeeper, stakingKeeper, distrtypes.ModuleName, authority.String(),
@@ -244,7 +244,7 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
244244
ValidatorAddress: f.valAddr.String(),
245245
},
246246
expErr: true,
247-
expErrMsg: "no delegation distribution info",
247+
expErrMsg: "no delegation for (address, validator) tuple",
248248
},
249249
{
250250
name: "validator with no delegations",
@@ -253,7 +253,7 @@ func TestMsgWithdrawDelegatorReward(t *testing.T) {
253253
ValidatorAddress: sdk.ValAddress(sdk.AccAddress(PKS[2].Address())).String(),
254254
},
255255
expErr: true,
256-
expErrMsg: "no validator distribution info",
256+
expErrMsg: "validator does not exist",
257257
},
258258
{
259259
name: "valid msg",
@@ -888,6 +888,9 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
888888
f.bankKeeper.MintCoins(f.sdkCtx, distrtypes.ModuleName, amt)
889889
f.bankKeeper.SendCoinsFromModuleToAccount(f.sdkCtx, distrtypes.ModuleName, addr, amt)
890890

891+
bondDenom, err := f.stakingKeeper.BondDenom(f.sdkCtx)
892+
require.NoError(t, err)
893+
891894
testCases := []struct {
892895
name string
893896
msg *distrtypes.MsgDepositValidatorRewardsPool
@@ -899,7 +902,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
899902
msg: &distrtypes.MsgDepositValidatorRewardsPool{
900903
Depositor: addr.String(),
901904
ValidatorAddress: valAddr1.String(),
902-
Amount: sdk.NewCoins(sdk.NewCoin(f.stakingKeeper.BondDenom(f.sdkCtx), sdk.NewInt(100))),
905+
Amount: sdk.NewCoins(sdk.NewCoin(bondDenom, sdk.NewInt(100))),
903906
},
904907
},
905908
{
@@ -915,7 +918,7 @@ func TestMsgDepositValidatorRewardsPool(t *testing.T) {
915918
msg: &distrtypes.MsgDepositValidatorRewardsPool{
916919
Depositor: addr.String(),
917920
ValidatorAddress: sdk.ValAddress([]byte("addr1_______________")).String(),
918-
Amount: sdk.NewCoins(sdk.NewCoin(f.stakingKeeper.BondDenom(f.sdkCtx), sdk.NewInt(100))),
921+
Amount: sdk.NewCoins(sdk.NewCoin(bondDenom, sdk.NewInt(100))),
919922
},
920923
expErr: true,
921924
expErrMsg: "validator does not exist",

tests/integration/evidence/keeper/infraction_test.go

+38-24
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func initFixture(t testing.TB) *fixture {
117117
log.NewNopLogger(),
118118
)
119119

120-
stakingKeeper := stakingkeeper.NewKeeper(cdc, keys[stakingtypes.StoreKey], accountKeeper, bankKeeper, authority.String())
120+
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String())
121121

122122
slashingKeeper := slashingkeeper.NewKeeper(cdc, codec.NewLegacyAmino(), runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), stakingKeeper, authority.String())
123123

@@ -164,35 +164,40 @@ func TestHandleDoubleSign(t *testing.T) {
164164
populateValidators(t, f)
165165

166166
power := int64(100)
167-
stakingParams := f.stakingKeeper.GetParams(ctx)
168-
operatorAddr, val := valAddresses[0], pubkeys[0]
167+
stakingParams, err := f.stakingKeeper.GetParams(ctx)
168+
assert.NilError(t, err)
169+
operatorAddr, valpubkey := valAddresses[0], pubkeys[0]
169170
tstaking := stakingtestutil.NewHelper(t, ctx, f.stakingKeeper)
170171

171-
selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true)
172+
selfDelegation := tstaking.CreateValidatorWithValPower(operatorAddr, valpubkey, power, true)
172173

173174
// execute end-blocker and verify validator attributes
174-
_, err := f.stakingKeeper.EndBlocker(f.sdkCtx)
175+
_, err = f.stakingKeeper.EndBlocker(f.sdkCtx)
175176
assert.NilError(t, err)
176177
assert.DeepEqual(t,
177178
f.bankKeeper.GetAllBalances(ctx, sdk.AccAddress(operatorAddr)).String(),
178179
sdk.NewCoins(sdk.NewCoin(stakingParams.BondDenom, initAmt.Sub(selfDelegation))).String(),
179180
)
180-
assert.DeepEqual(t, selfDelegation, f.stakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens())
181+
val, err := f.stakingKeeper.Validator(ctx, operatorAddr)
182+
assert.NilError(t, err)
183+
assert.DeepEqual(t, selfDelegation, val.GetBondedTokens())
181184

182-
assert.NilError(t, f.slashingKeeper.AddPubkey(f.sdkCtx, val))
185+
assert.NilError(t, f.slashingKeeper.AddPubkey(f.sdkCtx, valpubkey))
183186

184-
info := slashingtypes.NewValidatorSigningInfo(sdk.ConsAddress(val.Address()), f.sdkCtx.BlockHeight(), int64(0), time.Unix(0, 0), false, int64(0))
185-
f.slashingKeeper.SetValidatorSigningInfo(f.sdkCtx, sdk.ConsAddress(val.Address()), info)
187+
info := slashingtypes.NewValidatorSigningInfo(sdk.ConsAddress(valpubkey.Address()), f.sdkCtx.BlockHeight(), int64(0), time.Unix(0, 0), false, int64(0))
188+
f.slashingKeeper.SetValidatorSigningInfo(f.sdkCtx, sdk.ConsAddress(valpubkey.Address()), info)
186189

187190
// handle a signature to set signing info
188-
f.slashingKeeper.HandleValidatorSignature(ctx, val.Address(), selfDelegation.Int64(), comet.BlockIDFlagCommit)
191+
f.slashingKeeper.HandleValidatorSignature(ctx, valpubkey.Address(), selfDelegation.Int64(), comet.BlockIDFlagCommit)
189192

190193
// double sign less than max age
191-
oldTokens := f.stakingKeeper.Validator(ctx, operatorAddr).GetTokens()
194+
val, err = f.stakingKeeper.Validator(ctx, operatorAddr)
195+
assert.NilError(t, err)
196+
oldTokens := val.GetTokens()
192197

193198
nci := NewCometInfo(abci.RequestFinalizeBlock{
194199
Misbehavior: []abci.Misbehavior{{
195-
Validator: abci.Validator{Address: val.Address(), Power: power},
200+
Validator: abci.Validator{Address: valpubkey.Address(), Power: power},
196201
Type: abci.MisbehaviorType_DUPLICATE_VOTE,
197202
Time: time.Now().UTC(),
198203
Height: 1,
@@ -203,18 +208,22 @@ func TestHandleDoubleSign(t *testing.T) {
203208
assert.NilError(t, f.evidenceKeeper.BeginBlocker(ctx.WithCometInfo(nci)))
204209

205210
// should be jailed and tombstoned
206-
assert.Assert(t, f.stakingKeeper.Validator(ctx, operatorAddr).IsJailed())
207-
assert.Assert(t, f.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address())))
211+
val, err = f.stakingKeeper.Validator(ctx, operatorAddr)
212+
assert.NilError(t, err)
213+
assert.Assert(t, val.IsJailed())
214+
assert.Assert(t, f.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(valpubkey.Address())))
208215

209216
// tokens should be decreased
210-
newTokens := f.stakingKeeper.Validator(ctx, operatorAddr).GetTokens()
217+
newTokens := val.GetTokens()
211218
assert.Assert(t, newTokens.LT(oldTokens))
212219

213220
// submit duplicate evidence
214221
assert.NilError(t, f.evidenceKeeper.BeginBlocker(ctx))
215222

216223
// tokens should be the same (capped slash)
217-
assert.Assert(t, f.stakingKeeper.Validator(ctx, operatorAddr).GetTokens().Equal(newTokens))
224+
val, err = f.stakingKeeper.Validator(ctx, operatorAddr)
225+
assert.NilError(t, err)
226+
assert.Assert(t, val.GetTokens().Equal(newTokens))
218227

219228
// jump to past the unbonding period
220229
ctx = ctx.WithBlockTime(time.Unix(1, 0).Add(stakingParams.UnbondingTime))
@@ -247,25 +256,28 @@ func TestHandleDoubleSign_TooOld(t *testing.T) {
247256
populateValidators(t, f)
248257

249258
power := int64(100)
250-
stakingParams := f.stakingKeeper.GetParams(ctx)
251-
operatorAddr, val := valAddresses[0], pubkeys[0]
259+
stakingParams, err := f.stakingKeeper.GetParams(ctx)
260+
assert.NilError(t, err)
261+
operatorAddr, valpubkey := valAddresses[0], pubkeys[0]
252262

253263
tstaking := stakingtestutil.NewHelper(t, ctx, f.stakingKeeper)
254264

255-
amt := tstaking.CreateValidatorWithValPower(operatorAddr, val, power, true)
265+
amt := tstaking.CreateValidatorWithValPower(operatorAddr, valpubkey, power, true)
256266

257267
// execute end-blocker and verify validator attributes
258-
_, err := f.stakingKeeper.EndBlocker(f.sdkCtx)
268+
_, err = f.stakingKeeper.EndBlocker(f.sdkCtx)
259269
assert.NilError(t, err)
260270
assert.DeepEqual(t,
261271
f.bankKeeper.GetAllBalances(ctx, sdk.AccAddress(operatorAddr)),
262272
sdk.NewCoins(sdk.NewCoin(stakingParams.BondDenom, initAmt.Sub(amt))),
263273
)
264-
assert.DeepEqual(t, amt, f.stakingKeeper.Validator(ctx, operatorAddr).GetBondedTokens())
274+
val, err := f.stakingKeeper.Validator(ctx, operatorAddr)
275+
assert.NilError(t, err)
276+
assert.DeepEqual(t, amt, val.GetBondedTokens())
265277

266278
nci := NewCometInfo(abci.RequestFinalizeBlock{
267279
Misbehavior: []abci.Misbehavior{{
268-
Validator: abci.Validator{Address: val.Address(), Power: power},
280+
Validator: abci.Validator{Address: valpubkey.Address(), Power: power},
269281
Type: abci.MisbehaviorType_DUPLICATE_VOTE,
270282
Time: ctx.BlockTime(),
271283
Height: 0,
@@ -282,8 +294,10 @@ func TestHandleDoubleSign_TooOld(t *testing.T) {
282294

283295
assert.NilError(t, f.evidenceKeeper.BeginBlocker(ctx))
284296

285-
assert.Assert(t, f.stakingKeeper.Validator(ctx, operatorAddr).IsJailed() == false)
286-
assert.Assert(t, f.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address())) == false)
297+
val, err = f.stakingKeeper.Validator(ctx, operatorAddr)
298+
assert.NilError(t, err)
299+
assert.Assert(t, val.IsJailed() == false)
300+
assert.Assert(t, f.slashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(valpubkey.Address())) == false)
287301
}
288302

289303
func populateValidators(t assert.TestingT, f *fixture) {

tests/integration/gov/keeper/keeper_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func initFixture(t testing.TB) *fixture {
8787
log.NewNopLogger(),
8888
)
8989

90-
stakingKeeper := stakingkeeper.NewKeeper(cdc, keys[stakingtypes.StoreKey], accountKeeper, bankKeeper, authority.String())
90+
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String())
9191

9292
// set default staking params
9393
stakingKeeper.SetParams(newCtx, stakingtypes.DefaultParams())

0 commit comments

Comments
 (0)