Skip to content

Commit 4308c28

Browse files
authored
Cover the orphan index entry under ABCI queries too (#4695)
`TestGRPCQueryValidatorDelegationsOrphanIndexEntry`, added in #4688, only ran in the consensus context, which pages the delegation-by-validator index through `FilteredPaginateV66`. ABCI queries page it through `FilteredPaginate` instead, so the check that an index entry without its delegation returns `Internal` had no coverage on that path. The test now runs under both `abciQuery` values, like `TestGRPCQueryValidatorDelegationsScanCursorAfterIndexReady` beside it. Test-only, with no consensus or state impact. Both subtests fail with the nil guard in `validatorDelegationsFromIndex` removed.
1 parent 2949d8d commit 4308c28

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

‎sei-cosmos/x/staking/keeper/delegation_index_test.go‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,17 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorDelegationsScanCursorAfterIn
455455
// TestGRPCQueryValidatorDelegationsOrphanIndexEntry pins that an index entry without
456456
// its delegation fails the query rather than panicking it.
457457
func (suite *KeeperTestSuite) TestGRPCQueryValidatorDelegationsOrphanIndexEntry() {
458-
app, ctx := suite.app, suite.ctx
459-
suite.Require().True(app.StakingKeeper.DelegationByValIndexReady(ctx))
460-
valAddr := suite.vals[0].GetOperator()
461-
ctx.KVStore(app.StakingKeeper.GetStoreKey()).Set(types.GetDelegationByValIndexKey(delegatorAt(0x00, 1), valAddr), []byte{})
458+
for _, abciQuery := range []bool{false, true} {
459+
suite.Run(fmt.Sprintf("abciQuery=%v", abciQuery), func() {
460+
suite.SetupTest()
461+
app, ctx := suite.app, suite.ctx.WithIsABCIQuery(abciQuery)
462+
suite.Require().True(app.StakingKeeper.DelegationByValIndexReady(ctx))
463+
valAddr := suite.vals[0].GetOperator()
464+
ctx.KVStore(app.StakingKeeper.GetStoreKey()).Set(types.GetDelegationByValIndexKey(delegatorAt(0x00, 1), valAddr), []byte{})
462465

463-
querier := keeper.Querier{Keeper: app.StakingKeeper}
464-
_, err := querier.ValidatorDelegations(sdk.WrapSDKContext(ctx), &types.QueryValidatorDelegationsRequest{ValidatorAddr: valAddr.String()})
465-
suite.Require().Equal(codes.Internal, status.Code(err))
466+
querier := keeper.Querier{Keeper: app.StakingKeeper}
467+
_, err := querier.ValidatorDelegations(sdk.WrapSDKContext(ctx), &types.QueryValidatorDelegationsRequest{ValidatorAddr: valAddr.String()})
468+
suite.Require().Equal(codes.Internal, status.Code(err))
469+
})
470+
}
466471
}

0 commit comments

Comments
 (0)