update pagination tests (#8565)

This commit is contained in:
SaReN 2021-02-11 15:19:26 +05:30 committed by GitHub
parent dfc8dd813e
commit bddbc131fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 22 deletions

View File

@ -8,7 +8,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/query"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/bank/types"
) )
@ -32,7 +31,7 @@ func (s *paginationTestSuite) TestFilteredPaginations() {
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
app.AccountKeeper.SetAccount(ctx, acc1) app.AccountKeeper.SetAccount(ctx, acc1)
s.Require().NoError(app.BankKeeper.SetBalances(ctx, addr1, balances)) s.Require().NoError(app.BankKeeper.SetBalances(ctx, addr1, balances))
store := ctx.KVStore(app.GetKey(authtypes.StoreKey)) store := ctx.KVStore(app.GetKey(types.StoreKey))
// verify pagination with limit > total values // verify pagination with limit > total values
pageReq := &query.PageRequest{Key: nil, Limit: 5, CountTotal: true} pageReq := &query.PageRequest{Key: nil, Limit: 5, CountTotal: true}
@ -110,7 +109,7 @@ func ExampleFilteredPaginate() {
} }
pageReq := &query.PageRequest{Key: nil, Limit: 1, CountTotal: true} pageReq := &query.PageRequest{Key: nil, Limit: 1, CountTotal: true}
store := ctx.KVStore(app.GetKey(authtypes.StoreKey)) store := ctx.KVStore(app.GetKey(types.StoreKey))
balancesStore := prefix.NewStore(store, types.BalancesPrefix) balancesStore := prefix.NewStore(store, types.BalancesPrefix)
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))

View File

@ -19,9 +19,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address" "github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/types/query"
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/bank/types" "github.com/cosmos/cosmos-sdk/x/bank/types"
) )
@ -192,7 +189,7 @@ func ExamplePaginate() {
pageReq := &query.PageRequest{Key: nil, Limit: 1, CountTotal: true} pageReq := &query.PageRequest{Key: nil, Limit: 1, CountTotal: true}
request := types.NewQueryAllBalancesRequest(addr1, pageReq) request := types.NewQueryAllBalancesRequest(addr1, pageReq)
balResult := sdk.NewCoins() balResult := sdk.NewCoins()
authStore := ctx.KVStore(app.GetKey(authtypes.StoreKey)) authStore := ctx.KVStore(app.GetKey(types.StoreKey))
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix) balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error { pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error {
@ -222,20 +219,5 @@ func setupTest() (*simapp.SimApp, sdk.Context, codec.Marshaler) {
ms.LoadLatestVersion() ms.LoadLatestVersion()
maccPerms := simapp.GetMaccPerms()
maccPerms[holder] = nil
maccPerms[authtypes.Burner] = []string{authtypes.Burner}
maccPerms[authtypes.Minter] = []string{authtypes.Minter}
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
maccPerms[randomPerm] = []string{"random"}
app.AccountKeeper = authkeeper.NewAccountKeeper(
appCodec, app.GetKey(authtypes.StoreKey), app.GetSubspace(authtypes.ModuleName),
authtypes.ProtoBaseAccount, maccPerms,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, app.GetKey(authtypes.StoreKey), app.AccountKeeper,
app.GetSubspace(types.ModuleName), make(map[string]bool),
)
return app, ctx, appCodec return app, ctx, appCodec
} }