Add pagination response for commands (#6825)
* migrated auth cli to use grpc query client * unpacker added for account command * fxed tests * added grpc register in module.go * fixed grpc failing issue * page resonse added for console * added reference * paginations res added for commands * Fix auth cli tests Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
ceba0cb45d
commit
3322e269a1
|
@ -214,10 +214,10 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
|||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), val1.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var coins sdk.Coins
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
startTokens := coins.AmountOf(s.cfg.BondDenom)
|
||||
startTokens := balRes.Balances.AmountOf(s.cfg.BondDenom)
|
||||
|
||||
// Test generate sendTx, estimate gas
|
||||
finalGeneratedTx, err := bankcli.MsgSendExec(
|
||||
|
@ -284,9 +284,9 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
|||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), val1.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(startTokens, coins.AmountOf(s.cfg.BondDenom))
|
||||
s.Require().Equal(startTokens, balRes.Balances.AmountOf(s.cfg.BondDenom))
|
||||
|
||||
// Test broadcast
|
||||
|
||||
|
@ -307,15 +307,15 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
|||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), account.GetAddress())
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(sendTokens.Amount, coins.AmountOf(s.cfg.BondDenom))
|
||||
s.Require().Equal(sendTokens.Amount, balRes.Balances.AmountOf(s.cfg.BondDenom))
|
||||
|
||||
// Ensure origin account state
|
||||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), val1.Address)
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
|
@ -451,10 +451,10 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
|||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), multisigInfo.GetAddress())
|
||||
s.Require().NoError(err)
|
||||
|
||||
var coins sdk.Coins
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
intialCoins := coins
|
||||
intialCoins := balRes.Balances
|
||||
|
||||
// Send coins from validator to multisig.
|
||||
sendTokens := sdk.NewInt64Coin(s.cfg.BondDenom, 10)
|
||||
|
@ -475,9 +475,9 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
|||
resp, err = bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), multisigInfo.GetAddress())
|
||||
s.Require().NoError(err)
|
||||
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
diff, _ := coins.SafeSub(intialCoins)
|
||||
diff, _ := balRes.Balances.SafeSub(intialCoins)
|
||||
s.Require().Equal(sendTokens.Amount, diff.AmountOf(s.cfg.BondDenom))
|
||||
|
||||
// Generate multisig transaction.
|
||||
|
@ -567,10 +567,10 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
|||
resp, err := bankcli.QueryBalancesExec(val1.ClientCtx.WithOutputFormat("json"), multisigInfo.GetAddress())
|
||||
s.Require().NoError(err)
|
||||
|
||||
var coins sdk.Coins
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &coins)
|
||||
var balRes banktypes.QueryAllBalancesResponse
|
||||
err = val1.ClientCtx.JSONMarshaler.UnmarshalJSON(resp.Bytes(), &balRes)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(sendTokens.Amount, coins.AmountOf(s.cfg.BondDenom))
|
||||
s.Require().Equal(sendTokens.Amount, balRes.Balances.AmountOf(s.cfg.BondDenom))
|
||||
|
||||
// Generate multisig transaction.
|
||||
multiGeneratedTx, err := bankcli.MsgSendExec(
|
||||
|
|
|
@ -14,8 +14,10 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||
banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
|
@ -62,11 +64,14 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() {
|
|||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
&sdk.Coins{},
|
||||
sdk.NewCoins(
|
||||
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
|
||||
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Sub(s.cfg.BondedTokens)),
|
||||
),
|
||||
&types.QueryAllBalancesResponse{},
|
||||
&types.QueryAllBalancesResponse{
|
||||
Balances: sdk.NewCoins(
|
||||
sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens),
|
||||
sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Sub(s.cfg.BondedTokens)),
|
||||
),
|
||||
Pagination: &query.PageResponse{},
|
||||
},
|
||||
},
|
||||
{
|
||||
"total account balance of a specific denom",
|
||||
|
|
|
@ -84,7 +84,7 @@ Example:
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return clientCtx.PrintOutput(res.Balances)
|
||||
return clientCtx.PrintOutput(res)
|
||||
}
|
||||
|
||||
params := types.NewQueryBalanceRequest(addr, denom)
|
||||
|
|
|
@ -299,7 +299,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorSlashes() {
|
|||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
},
|
||||
false,
|
||||
"null",
|
||||
"{\"slashes\":null,\"pagination\":{}}",
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
|
@ -309,7 +309,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorSlashes() {
|
|||
sdk.ValAddress(val.Address).String(), "1", "3",
|
||||
},
|
||||
false,
|
||||
"null",
|
||||
"pagination: {}\nslashes: null",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ $ %s query distribution slashes cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmq
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.GetSlashes())
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -155,10 +155,10 @@ $ %s query gov proposals --page=2 --limit=100
|
|||
}
|
||||
|
||||
if len(res.GetProposals()) == 0 {
|
||||
return fmt.Errorf("no matching proposals found")
|
||||
return fmt.Errorf("no proposals found")
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.GetProposals())
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -311,11 +311,12 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
|
|||
context.Background(),
|
||||
&types.QueryVotesRequest{ProposalId: proposalID, Pagination: pageReq},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.GetVotes())
|
||||
return clientCtx.PrintOutput(res)
|
||||
|
||||
},
|
||||
}
|
||||
|
@ -458,11 +459,12 @@ $ %s query gov deposits 1
|
|||
context.Background(),
|
||||
&types.QueryDepositsRequest{ProposalId: proposalID, Pagination: pageReq},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.GetDeposits())
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ $ <appcli> query slashing signing-infos
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.Info)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ $ %s query staking unbonding-delegations-from cosmosvaloper1gghjut3ccd8ay0zduzj6
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.UnbondingResponses)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ $ %s query staking redelegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.RedelegationResponses)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -342,7 +342,7 @@ $ %s query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.DelegationResponses)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -397,7 +397,7 @@ $ %s query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.DelegationResponses)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -506,7 +506,7 @@ $ %s query staking unbonding-delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.UnbondingResponses)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -621,7 +621,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
|
|||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.RedelegationResponses)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue