refactor(client): use address codec (#17503)

This commit is contained in:
Julien Robert
2023-08-23 10:43:47 +00:00
committed by GitHub
parent 029f9ed71e
commit c6b0bb62ac
42 changed files with 428 additions and 224 deletions
+9 -6
View File
@@ -15,7 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec/address"
addresscodec "github.com/cosmos/cosmos-sdk/codec/address"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/cosmos/cosmos-sdk/testutil"
@@ -52,7 +52,10 @@ func (s *CLITestSuite) SetupSuite() {
WithClient(clitestutil.MockCometRPC{Client: rpcclientmock.Client{}}).
WithAccountRetriever(client.MockAccountRetriever{}).
WithOutput(io.Discard).
WithChainID("test-chain")
WithChainID("test-chain").
WithAddressCodec(addresscodec.NewBech32Codec("cosmos")).
WithValidatorAddressCodec(addresscodec.NewBech32Codec("cosmosvaloper")).
WithConsensusAddressCodec(addresscodec.NewBech32Codec("cosmosvalcons"))
ctxGen := func() client.Context {
bz, _ := s.encCfg.Codec.Marshal(&sdk.TxResponse{})
@@ -133,7 +136,7 @@ func (s *CLITestSuite) TestTxWithdrawRewardsCmd() {
args := append([]string{tc.valAddr.String()}, tc.args...)
ctx := svrcmd.CreateExecuteContext(context.Background())
cmd := cli.NewWithdrawRewardsCmd(address.NewBech32Codec("cosmosvaloper"), address.NewBech32Codec("cosmos"))
cmd := cli.NewWithdrawRewardsCmd(addresscodec.NewBech32Codec("cosmosvaloper"), addresscodec.NewBech32Codec("cosmos"))
cmd.SetContext(ctx)
cmd.SetArgs(args)
s.Require().NoError(client.SetCmdClientContextHandler(s.clientCtx, cmd))
@@ -185,7 +188,7 @@ func (s *CLITestSuite) TestTxWithdrawAllRewardsCmd() {
tc := tc
s.Run(tc.name, func() {
cmd := cli.NewWithdrawAllRewardsCmd(address.NewBech32Codec("cosmosvaloper"), address.NewBech32Codec("cosmos"))
cmd := cli.NewWithdrawAllRewardsCmd(addresscodec.NewBech32Codec("cosmosvaloper"), addresscodec.NewBech32Codec("cosmos"))
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args)
if tc.expectErrMsg != "" {
@@ -237,7 +240,7 @@ func (s *CLITestSuite) TestTxSetWithdrawAddrCmd() {
tc := tc
s.Run(tc.name, func() {
cmd := cli.NewSetWithdrawAddrCmd(address.NewBech32Codec("cosmos"))
cmd := cli.NewSetWithdrawAddrCmd(addresscodec.NewBech32Codec("cosmos"))
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args)
if tc.expectErr {
@@ -287,7 +290,7 @@ func (s *CLITestSuite) TestTxFundCommunityPoolCmd() {
tc := tc
s.Run(tc.name, func() {
cmd := cli.NewFundCommunityPoolCmd(address.NewBech32Codec("cosmos"))
cmd := cli.NewFundCommunityPoolCmd(addresscodec.NewBech32Codec("cosmos"))
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, tc.args)
if tc.expectErr {