refactor: clean-up test helpers and tmcli (#13805)
This commit is contained in:
parent
76be73022a
commit
4f7d9ea233
@ -5,8 +5,6 @@ import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -52,7 +50,7 @@ func runConfigCmd(cmd *cobra.Command, args []string) error {
|
||||
cmd.Println(conf.ChainID)
|
||||
case flags.FlagKeyringBackend:
|
||||
cmd.Println(conf.KeyringBackend)
|
||||
case tmcli.OutputFlag:
|
||||
case flags.FlagOutput:
|
||||
cmd.Println(conf.Output)
|
||||
case flags.FlagNode:
|
||||
cmd.Println(conf.Node)
|
||||
@ -72,7 +70,7 @@ func runConfigCmd(cmd *cobra.Command, args []string) error {
|
||||
conf.SetChainID(value)
|
||||
case flags.FlagKeyringBackend:
|
||||
conf.SetKeyringBackend(value)
|
||||
case tmcli.OutputFlag:
|
||||
case flags.FlagOutput:
|
||||
conf.SetOutput(value)
|
||||
case flags.FlagNode:
|
||||
conf.SetNode(value)
|
||||
|
||||
@ -76,7 +76,9 @@ const (
|
||||
FlagReverse = "reverse"
|
||||
FlagTip = "tip"
|
||||
FlagAux = "aux"
|
||||
FlagOutput = tmcli.OutputFlag
|
||||
// FlagOutput is the flag to set the output format.
|
||||
// This differs from FlagOutputDocument that is used to set the output file.
|
||||
FlagOutput = tmcli.OutputFlag
|
||||
|
||||
// Tendermint logging flags
|
||||
FlagLogLevel = "log_level"
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -59,7 +58,7 @@ func ValidatorCommand() *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.Flags().String(flags.FlagNode, "tcp://localhost:26657", "<host>:<port> to Tendermint RPC interface for this chain")
|
||||
cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)")
|
||||
cmd.Flags().StringP(flags.FlagOutput, "o", "text", "Output format (text|json)")
|
||||
cmd.Flags().Int(flags.FlagPage, query.DefaultPage, "Query a specific page of paginated results")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "Query number of results returned per page")
|
||||
|
||||
|
||||
@ -1,118 +0,0 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
)
|
||||
|
||||
func TxSignExec(clientCtx client.Context, from fmt.Stringer, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
fmt.Sprintf("--from=%s", from.String()),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagHome, strings.Replace(clientCtx.HomeDir, "simd", "simcli", 1)),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID),
|
||||
filename,
|
||||
}
|
||||
|
||||
cmd := cli.GetSignCommand()
|
||||
tmcli.PrepareBaseCmd(cmd, "", "")
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cmd, append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxBroadcastExec(clientCtx client.Context, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
filename,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetBroadcastCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxEncodeExec(clientCtx client.Context, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
filename,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetEncodeCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxValidateSignaturesExec(clientCtx client.Context, filename string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID),
|
||||
filename,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetValidateSignaturesCommand(), args)
|
||||
}
|
||||
|
||||
func TxMultiSignExec(clientCtx client.Context, from string, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, clientCtx.ChainID),
|
||||
filename,
|
||||
from,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxSignBatchExec(clientCtx client.Context, from fmt.Stringer, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
fmt.Sprintf("--from=%s", from.String()),
|
||||
filename,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetSignBatchCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxDecodeExec(clientCtx client.Context, encodedTx string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
encodedTx,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetDecodeCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxMultiSignBatchExec(clientCtx client.Context, filename string, from string, sigFile1 string, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
filename,
|
||||
from,
|
||||
sigFile1,
|
||||
sigFile2,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignBatchCmd(), args)
|
||||
}
|
||||
|
||||
// TxAuxToFeeExec executes `GetAuxToFeeCommand` cli command with given args.
|
||||
func TxAuxToFeeExec(clientCtx client.Context, filename string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
filename,
|
||||
}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAuxToFeeCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
// DONTCOVER
|
||||
@ -17,11 +17,7 @@ import (
|
||||
"cosmossdk.io/depinject"
|
||||
"cosmossdk.io/math"
|
||||
|
||||
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
@ -35,6 +31,8 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
authclitestutil "github.com/cosmos/cosmos-sdk/x/auth/client/testutil"
|
||||
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
@ -103,7 +101,7 @@ func (s *IntegrationTestSuite) TestCLIValidateSignatures() {
|
||||
// write unsigned tx to file
|
||||
unsignedTx := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||
defer unsignedTx.Close()
|
||||
res, err = TxSignExec(val.ClientCtx, val.Address, unsignedTx.Name())
|
||||
res, err = authclitestutil.TxSignExec(val.ClientCtx, val.Address, unsignedTx.Name())
|
||||
s.Require().NoError(err)
|
||||
signedTx, err := val.ClientCtx.TxConfig.TxJSONDecoder()(res.Bytes())
|
||||
s.Require().NoError(err)
|
||||
@ -112,7 +110,7 @@ func (s *IntegrationTestSuite) TestCLIValidateSignatures() {
|
||||
defer signedTxFile.Close()
|
||||
txBuilder, err := val.ClientCtx.TxConfig.WrapTxBuilder(signedTx)
|
||||
s.Require().NoError(err)
|
||||
_, err = TxValidateSignaturesExec(val.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxValidateSignaturesExec(val.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
txBuilder.SetMemo("MODIFIED TX")
|
||||
@ -122,7 +120,7 @@ func (s *IntegrationTestSuite) TestCLIValidateSignatures() {
|
||||
modifiedTxFile := testutil.WriteToNewTempFile(s.T(), string(bz))
|
||||
defer modifiedTxFile.Close()
|
||||
|
||||
_, err = TxValidateSignaturesExec(val.ClientCtx, modifiedTxFile.Name())
|
||||
_, err = authclitestutil.TxValidateSignaturesExec(val.ClientCtx, modifiedTxFile.Name())
|
||||
s.Require().EqualError(err, "signatures validation failed")
|
||||
}
|
||||
|
||||
@ -236,7 +234,7 @@ func (s *IntegrationTestSuite) TestCLISignGenOnly() {
|
||||
func() {
|
||||
signedTx := testutil.WriteToNewTempFile(s.T(), out.String())
|
||||
defer signedTx.Close()
|
||||
_, err := TxBroadcastExec(val.ClientCtx, signedTx.Name())
|
||||
_, err := authclitestutil.TxBroadcastExec(val.ClientCtx, signedTx.Name())
|
||||
s.Require().NoError(err)
|
||||
}()
|
||||
}
|
||||
@ -259,40 +257,40 @@ func (s *IntegrationTestSuite) TestCLISignBatch() {
|
||||
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||
|
||||
// sign-batch file - offline is set but account-number and sequence are not
|
||||
_, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--offline")
|
||||
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--offline")
|
||||
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
|
||||
|
||||
// sign-batch file - offline and sequence is set but account-number is not set
|
||||
_, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), "--offline")
|
||||
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), "--offline")
|
||||
s.Require().EqualError(err, "required flag(s) \"account-number\" not set")
|
||||
|
||||
// sign-batch file - offline and account-number is set but sequence is not set
|
||||
_, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"), "--offline")
|
||||
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"), "--offline")
|
||||
s.Require().EqualError(err, "required flag(s) \"sequence\" not set")
|
||||
|
||||
// sign-batch file - sequence and account-number are set when offline is false
|
||||
res, err := TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"))
|
||||
res, err := authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), fmt.Sprintf("--%s=%s", flags.FlagSequence, "1"), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, "1"))
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
|
||||
// sign-batch file
|
||||
res, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
||||
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
|
||||
// sign-batch file signature only
|
||||
res, err = TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
|
||||
// Sign batch malformed tx file.
|
||||
malformedFile := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf("%smalformed", generatedStd))
|
||||
defer malformedFile.Close()
|
||||
_, err = TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
||||
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID))
|
||||
s.Require().Error(err)
|
||||
|
||||
// Sign batch malformed tx file signature only.
|
||||
_, err = TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
_, err = authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, malformedFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
s.Require().Error(err)
|
||||
|
||||
// make a txn to increase the sequence of sender
|
||||
@ -320,7 +318,7 @@ func (s *IntegrationTestSuite) TestCLISignBatch() {
|
||||
s.Require().Equal(seq+1, seq1)
|
||||
|
||||
// signing sign-batch should start from the last sequence.
|
||||
signed, err := TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
signed, err := authclitestutil.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
signedTxs := strings.Split(strings.Trim(signed.String(), "\n"), "\n")
|
||||
s.Require().GreaterOrEqual(len(signedTxs), 1)
|
||||
@ -340,17 +338,17 @@ func (s *IntegrationTestSuite) TestCliGetAccountAddressByID() {
|
||||
}{
|
||||
{
|
||||
"not enough args",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"invalid account id",
|
||||
[]string{fmt.Sprint(-1), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprint(-1), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"valid account id",
|
||||
[]string{fmt.Sprint(0), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprint(0), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -397,13 +395,13 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() {
|
||||
require.NoError(err)
|
||||
|
||||
// query account info
|
||||
queryResJSON, err := QueryAccountExec(val1.ClientCtx, val1.Address)
|
||||
queryResJSON, err := authclitestutil.QueryAccountExec(val1.ClientCtx, val1.Address)
|
||||
require.NoError(err)
|
||||
var account authtypes.AccountI
|
||||
require.NoError(val1.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
||||
|
||||
/**** test signature-only ****/
|
||||
res, err := TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag,
|
||||
res, err := authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag,
|
||||
sigOnlyFlag, signModeAminoFlag)
|
||||
require.NoError(err)
|
||||
pub, err := valRecord.GetPubKey()
|
||||
@ -415,7 +413,7 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() {
|
||||
require.Equal(account.GetSequence(), sigs[0].Sequence)
|
||||
|
||||
/**** test full output ****/
|
||||
res, err = TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, signModeAminoFlag)
|
||||
res, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, signModeAminoFlag)
|
||||
require.NoError(err)
|
||||
|
||||
// txCfg.UnmarshalSignatureJSON can't unmarshal a fragment of the signature, so we create this structure.
|
||||
@ -430,14 +428,14 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() {
|
||||
/**** test file output ****/
|
||||
filenameSigned := filepath.Join(s.T().TempDir(), "test_sign_out.json")
|
||||
fileFlag := fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, filenameSigned)
|
||||
_, err = TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, fileFlag, signModeAminoFlag)
|
||||
_, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, fileUnsigned.Name(), chainFlag, fileFlag, signModeAminoFlag)
|
||||
require.NoError(err)
|
||||
fContent, err := os.ReadFile(filenameSigned)
|
||||
require.NoError(err)
|
||||
require.Equal(res.String(), string(fContent))
|
||||
|
||||
/**** try to append to the previously signed transaction ****/
|
||||
res, err = TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||
res, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||
sigOnlyFlag, signModeAminoFlag)
|
||||
require.NoError(err)
|
||||
checkSignatures(require, txCfg, res.Bytes(), pub, pub)
|
||||
@ -448,13 +446,13 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() {
|
||||
// account. Changing the file is too much hacking, because TxDecoder returns sdk.Tx, which doesn't
|
||||
// provide functionality to check / manage `auth_info`.
|
||||
// Cases with different keys are are covered in unit tests of `tx.Sign`.
|
||||
res, err = TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||
res, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||
sigOnlyFlag, "--overwrite", signModeAminoFlag)
|
||||
require.NoError(err)
|
||||
checkSignatures(require, txCfg, res.Bytes(), pub)
|
||||
|
||||
/**** test flagAmino ****/
|
||||
res, err = TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||
res, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, filenameSigned, chainFlag,
|
||||
"--amino=true", signModeAminoFlag)
|
||||
require.NoError(err)
|
||||
|
||||
@ -511,17 +509,17 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByHash() {
|
||||
},
|
||||
{
|
||||
"with invalid hash",
|
||||
[]string{"somethinginvalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"somethinginvalid", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true, "",
|
||||
},
|
||||
{
|
||||
"with valid and not existing hash",
|
||||
[]string{"C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true, "",
|
||||
},
|
||||
{
|
||||
"happy case",
|
||||
[]string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
sdk.MsgTypeURL(&banktypes.MsgSend{}),
|
||||
},
|
||||
@ -570,7 +568,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// Query the tx by hash to get the inner tx.
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
|
||||
protoTx := txRes.GetTx().(*tx.Tx)
|
||||
@ -586,7 +584,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
fmt.Sprintf("--type=%s", "foo"),
|
||||
"bar",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, "unknown --type value foo",
|
||||
},
|
||||
@ -595,7 +593,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=acc_seq",
|
||||
"",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, "`acc_seq` type takes an argument '<addr>/<seq>'",
|
||||
},
|
||||
@ -604,7 +602,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=acc_seq",
|
||||
"foobar",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, "found no txs matching given address and sequence combination",
|
||||
},
|
||||
@ -613,7 +611,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=acc_seq",
|
||||
fmt.Sprintf("%s/%d", val.Address, protoTx.AuthInfo.SignerInfos[0].Sequence),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, "",
|
||||
},
|
||||
@ -622,7 +620,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=signature",
|
||||
"",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, "argument should be comma-separated signatures",
|
||||
},
|
||||
@ -631,7 +629,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=signature",
|
||||
"foo",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, "found no txs matching given signatures",
|
||||
},
|
||||
@ -640,7 +638,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=signature",
|
||||
base64.StdEncoding.EncodeToString(protoTx.Signatures[0]),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, "",
|
||||
},
|
||||
@ -687,7 +685,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// Query the tx by hash to get the inner tx.
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes))
|
||||
|
||||
@ -701,7 +699,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() {
|
||||
[]string{
|
||||
fmt.Sprintf("--events=tx.fee=%s",
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -710,7 +708,7 @@ func (s *IntegrationTestSuite) TestCLIQueryTxsCmdByEvents() {
|
||||
[]string{
|
||||
fmt.Sprintf("--events=tx.fee=%s",
|
||||
sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0))).String()),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -807,23 +805,23 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
defer unsignedTxFile.Close()
|
||||
|
||||
// Test validate-signatures
|
||||
res, err := TxValidateSignaturesExec(val1.ClientCtx, unsignedTxFile.Name())
|
||||
res, err := authclitestutil.TxValidateSignaturesExec(val1.ClientCtx, unsignedTxFile.Name())
|
||||
s.Require().EqualError(err, "signatures validation failed")
|
||||
s.Require().True(strings.Contains(res.String(), fmt.Sprintf("Signers:\n 0: %v\n\nSignatures:\n\n", val1.Address.String())))
|
||||
|
||||
// Test sign
|
||||
|
||||
// Does not work in offline mode
|
||||
_, err = TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline")
|
||||
_, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline")
|
||||
s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set")
|
||||
|
||||
// But works offline if we set account number and sequence
|
||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||
_, err = TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1")
|
||||
_, err = authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1")
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Sign transaction
|
||||
signedTx, err := TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name())
|
||||
signedTx, err := authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
signedFinalTx, err := txCfg.TxJSONDecoder()(signedTx.Bytes())
|
||||
s.Require().NoError(err)
|
||||
@ -840,7 +838,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
defer signedTxFile.Close()
|
||||
|
||||
// validate Signature
|
||||
res, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||
res, err = authclitestutil.TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
s.Require().True(strings.Contains(res.String(), "[OK]"))
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
@ -856,13 +854,13 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
|
||||
// Test broadcast
|
||||
|
||||
// Does not work in offline mode
|
||||
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name(), "--offline")
|
||||
_, err = authclitestutil.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name(), "--offline")
|
||||
s.Require().EqualError(err, "cannot broadcast tx during offline mode")
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// Broadcast correct transaction.
|
||||
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
|
||||
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
@ -928,20 +926,20 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() {
|
||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||
addr1, err := account1.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
account1Signature, err := TxSignExec(val1.ClientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
account1Signature, err := authclitestutil.TxSignExec(val1.ClientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
s.Require().NoError(err)
|
||||
|
||||
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
||||
defer sign1File.Close()
|
||||
|
||||
multiSigWith1Signature, err := TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name())
|
||||
multiSigWith1Signature, err := authclitestutil.TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Save tx to file
|
||||
multiSigWith1SignatureFile := testutil.WriteToNewTempFile(s.T(), multiSigWith1Signature.String())
|
||||
defer multiSigWith1SignatureFile.Close()
|
||||
|
||||
_, err = TxValidateSignaturesExec(val1.ClientCtx, multiSigWith1SignatureFile.Name())
|
||||
_, err = authclitestutil.TxValidateSignaturesExec(val1.ClientCtx, multiSigWith1SignatureFile.Name())
|
||||
s.Require().Error(err)
|
||||
}
|
||||
|
||||
@ -961,12 +959,12 @@ func (s *IntegrationTestSuite) TestCLIEncode() {
|
||||
defer savedTxFile.Close()
|
||||
|
||||
// Encode
|
||||
encodeExec, err := TxEncodeExec(val1.ClientCtx, savedTxFile.Name())
|
||||
encodeExec, err := authclitestutil.TxEncodeExec(val1.ClientCtx, savedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
trimmedBase64 := strings.Trim(encodeExec.String(), "\"\n")
|
||||
|
||||
// Check that the transaction decodes as expected
|
||||
decodedTx, err := TxDecodeExec(val1.ClientCtx, trimmedBase64)
|
||||
decodedTx, err := authclitestutil.TxDecodeExec(val1.ClientCtx, trimmedBase64)
|
||||
s.Require().NoError(err)
|
||||
|
||||
txCfg := val1.ClientCtx.TxConfig
|
||||
@ -1046,7 +1044,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||
addr1, err := account1.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||
account1Signature, err := TxSignExec(val1.ClientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
account1Signature, err := authclitestutil.TxSignExec(val1.ClientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
s.Require().NoError(err)
|
||||
|
||||
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
||||
@ -1055,7 +1053,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||
// Sign with account2
|
||||
addr2, err := account2.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
account2Signature, err := TxSignExec(val1.ClientCtx, addr2, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
account2Signature, err := authclitestutil.TxSignExec(val1.ClientCtx, addr2, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
s.Require().NoError(err)
|
||||
|
||||
sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
|
||||
@ -1064,22 +1062,22 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() {
|
||||
// Sign with dummy account
|
||||
dummyAddr, err := dummyAcc.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
_, err = TxSignExec(val1.ClientCtx, dummyAddr, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
_, err = authclitestutil.TxSignExec(val1.ClientCtx, dummyAddr, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), "signing key is not a part of multisig key")
|
||||
|
||||
multiSigWith2Signatures, err := TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
||||
multiSigWith2Signatures, err := authclitestutil.TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Write the output to disk
|
||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
|
||||
defer signedTxFile.Close()
|
||||
|
||||
_, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
|
||||
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
@ -1123,7 +1121,7 @@ func (s *IntegrationTestSuite) TestSignWithMultisig() {
|
||||
// even though the tx signer is NOT the multisig address. This is fine though,
|
||||
// as the main point of this test is to test the `--multisig` flag with an address
|
||||
// that is not in the keyring.
|
||||
_, err = TxSignExec(val1.ClientCtx, addr1, multiGeneratedTx2File.Name(), "--multisig", multisigAddr.String())
|
||||
_, err = authclitestutil.TxSignExec(val1.ClientCtx, addr1, multiGeneratedTx2File.Name(), "--multisig", multisigAddr.String())
|
||||
s.Require().Contains(err.Error(), "error getting account from keybase")
|
||||
}
|
||||
|
||||
@ -1184,7 +1182,7 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
||||
s.Require().NoError(err)
|
||||
// Sign with account1
|
||||
val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||
account1Signature, err := TxSignExec(val1.ClientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
account1Signature, err := authclitestutil.TxSignExec(val1.ClientCtx, addr1, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
s.Require().NoError(err)
|
||||
|
||||
sign1File := testutil.WriteToNewTempFile(s.T(), account1Signature.String())
|
||||
@ -1193,29 +1191,29 @@ func (s *IntegrationTestSuite) TestCLIMultisign() {
|
||||
addr2, err := account2.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
// Sign with account2
|
||||
account2Signature, err := TxSignExec(val1.ClientCtx, addr2, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
account2Signature, err := authclitestutil.TxSignExec(val1.ClientCtx, addr2, multiGeneratedTxFile.Name(), "--multisig", addr.String())
|
||||
s.Require().NoError(err)
|
||||
|
||||
sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String())
|
||||
defer sign2File.Close()
|
||||
|
||||
// Does not work in offline mode.
|
||||
_, err = TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name())
|
||||
_, err = authclitestutil.TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name())
|
||||
s.Require().EqualError(err, fmt.Sprintf("couldn't verify signature for address %s", addr1))
|
||||
|
||||
val1.ClientCtx.Offline = false
|
||||
multiSigWith2Signatures, err := TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
||||
multiSigWith2Signatures, err := authclitestutil.TxMultiSignExec(val1.ClientCtx, multisigRecord.Name, multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Write the output to disk
|
||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), multiSigWith2Signatures.String())
|
||||
defer signedTxFile.Close()
|
||||
|
||||
_, err = TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxValidateSignaturesExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
|
||||
_, err = TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
@ -1266,7 +1264,7 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() {
|
||||
addr1, err := account1.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
// sign-batch file
|
||||
res, err := TxSignBatchExec(val.ClientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
|
||||
res, err := authclitestutil.TxSignBatchExec(val.ClientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
// write sigs to file
|
||||
@ -1276,13 +1274,13 @@ func (s *IntegrationTestSuite) TestSignBatchMultisig() {
|
||||
addr2, err := account2.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
// sign-batch file with account2
|
||||
res, err = TxSignBatchExec(val.ClientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
|
||||
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(1, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
// write sigs to file2
|
||||
file2 := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||
defer file2.Close()
|
||||
_, err = TxMultiSignExec(val.ClientCtx, multisigRecord.Name, filename.Name(), file1.Name(), file2.Name())
|
||||
_, err = authclitestutil.TxMultiSignExec(val.ClientCtx, multisigRecord.Name, filename.Name(), file1.Name(), file2.Name())
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
@ -1328,7 +1326,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||
defer filename.Close()
|
||||
val.ClientCtx.HomeDir = strings.Replace(val.ClientCtx.HomeDir, "simd", "simcli", 1)
|
||||
|
||||
queryResJSON, err := QueryAccountExec(val.ClientCtx, addr)
|
||||
queryResJSON, err := authclitestutil.QueryAccountExec(val.ClientCtx, addr)
|
||||
s.Require().NoError(err)
|
||||
var account authtypes.AccountI
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account))
|
||||
@ -1336,7 +1334,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||
// sign-batch file
|
||||
addr1, err := account1.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
res, err := TxSignBatchExec(val.ClientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
|
||||
res, err := authclitestutil.TxSignBatchExec(val.ClientCtx, addr1, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
// write sigs to file
|
||||
@ -1346,14 +1344,14 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||
// sign-batch file with account2
|
||||
addr2, err := account2.GetAddress()
|
||||
s.Require().NoError(err)
|
||||
res, err = TxSignBatchExec(val.ClientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
|
||||
res, err = authclitestutil.TxSignBatchExec(val.ClientCtx, addr2, filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", addr.String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence())), "--signature-only")
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n")))
|
||||
|
||||
// multisign the file
|
||||
file2 := testutil.WriteToNewTempFile(s.T(), res.String())
|
||||
defer file2.Close()
|
||||
res, err = TxMultiSignBatchExec(val.ClientCtx, filename.Name(), multisigRecord.Name, file1.Name(), file2.Name())
|
||||
res, err = authclitestutil.TxMultiSignBatchExec(val.ClientCtx, filename.Name(), multisigRecord.Name, file1.Name(), file2.Name())
|
||||
s.Require().NoError(err)
|
||||
signedTxs := strings.Split(strings.Trim(res.String(), "\n"), "\n")
|
||||
|
||||
@ -1363,7 +1361,7 @@ func (s *IntegrationTestSuite) TestMultisignBatch() {
|
||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx)
|
||||
defer signedTxFile.Close()
|
||||
val.ClientCtx.BroadcastMode = flags.BroadcastSync
|
||||
_, err = TxBroadcastExec(val.ClientCtx, signedTxFile.Name())
|
||||
_, err = authclitestutil.TxBroadcastExec(val.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
}()
|
||||
@ -1396,7 +1394,7 @@ func (s *IntegrationTestSuite) TestGetAccountCmd() {
|
||||
s.Run(tc.name, func() {
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := QueryAccountExec(clientCtx, tc.address)
|
||||
out, err := authclitestutil.QueryAccountExec(clientCtx, tc.address)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().NotEqual("internal", err.Error())
|
||||
@ -1414,7 +1412,7 @@ func (s *IntegrationTestSuite) TestGetAccountsCmd() {
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, authcli.GetAccountsCmd(), []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
@ -1450,7 +1448,7 @@ func (s *IntegrationTestSuite) TestQueryModuleAccountByNameCmd() {
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, authcli.QueryModuleAccountByNameCmd(), []string{
|
||||
tc.moduleName,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
})
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
@ -1459,11 +1457,11 @@ func (s *IntegrationTestSuite) TestQueryModuleAccountByNameCmd() {
|
||||
var res authtypes.QueryModuleAccountByNameResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res))
|
||||
|
||||
var account types.AccountI
|
||||
var account authtypes.AccountI
|
||||
err := val.ClientCtx.InterfaceRegistry.UnpackAny(res.Account, &account)
|
||||
s.Require().NoError(err)
|
||||
|
||||
moduleAccount, ok := account.(types.ModuleAccountI)
|
||||
moduleAccount, ok := account.(authtypes.ModuleAccountI)
|
||||
s.Require().True(ok)
|
||||
s.Require().Equal(tc.moduleName, moduleAccount.GetName())
|
||||
}
|
||||
@ -1476,7 +1474,7 @@ func (s *IntegrationTestSuite) TestQueryModuleAccountsCmd() {
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, authcli.QueryModuleAccountsCmd(), []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
})
|
||||
s.Require().NoError(err)
|
||||
|
||||
@ -1537,12 +1535,12 @@ func (s *IntegrationTestSuite) TestQueryParamsCmd() {
|
||||
}{
|
||||
{
|
||||
"happy case",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"with specific height",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -1600,7 +1598,7 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() {
|
||||
defer unsignedTxFile.Close()
|
||||
|
||||
// Sign the file with the unsignedTx.
|
||||
signedTx, err := TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), fmt.Sprintf("--%s=true", cli.FlagOverwrite))
|
||||
signedTx, err := authclitestutil.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), fmt.Sprintf("--%s=true", cli.FlagOverwrite))
|
||||
s.Require().NoError(err)
|
||||
|
||||
// Remove the signerInfo's `public_key` field manually from the signedTx.
|
||||
@ -1619,7 +1617,7 @@ func (s *IntegrationTestSuite) TestTxWithoutPublicKey() {
|
||||
|
||||
// Broadcast tx, test that it shouldn't panic.
|
||||
val1.ClientCtx.BroadcastMode = flags.BroadcastSync
|
||||
out, err := TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
out, err := authclitestutil.TxBroadcastExec(val1.ClientCtx, signedTxFile.Name())
|
||||
s.Require().NoError(err)
|
||||
var res sdk.TxResponse
|
||||
s.Require().NoError(val1.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res))
|
||||
@ -1657,7 +1655,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
|
||||
defer unsignedTxFile.Close()
|
||||
|
||||
// Let val0 sign first the file with the unsignedTx.
|
||||
signedByVal0, err := TxSignExec(val0.ClientCtx, val0.Address, unsignedTxFile.Name(), "--overwrite", "--sign-mode=amino-json")
|
||||
signedByVal0, err := authclitestutil.TxSignExec(val0.ClientCtx, val0.Address, unsignedTxFile.Name(), "--overwrite", "--sign-mode=amino-json")
|
||||
require.NoError(err)
|
||||
signedByVal0File := testutil.WriteToNewTempFile(s.T(), signedByVal0.String())
|
||||
defer signedByVal0File.Close()
|
||||
@ -1666,7 +1664,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
|
||||
val1AccNum, val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountNumberSequence(val0.ClientCtx, val1.Address)
|
||||
require.NoError(err)
|
||||
|
||||
signedTx, err := TxSignExec(
|
||||
signedTx, err := authclitestutil.TxSignExec(
|
||||
val1.ClientCtx,
|
||||
val1.Address,
|
||||
signedByVal0File.Name(),
|
||||
@ -1679,7 +1677,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
|
||||
signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String())
|
||||
defer signedTxFile.Close()
|
||||
|
||||
res, err := TxBroadcastExec(
|
||||
res, err := authclitestutil.TxBroadcastExec(
|
||||
val0.ClientCtx,
|
||||
signedTxFile.Name(),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
|
||||
@ -1979,7 +1977,7 @@ func (s *IntegrationTestSuite) TestAuxToFeeWithTips() {
|
||||
defer genTxFile.Close()
|
||||
|
||||
// broadcast the tx
|
||||
res, err = TxAuxToFeeExec(
|
||||
res, err = authclitestutil.TxAuxToFeeExec(
|
||||
val.ClientCtx,
|
||||
genTxFile.Name(),
|
||||
tc.feePayerArgs...,
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
@ -108,7 +109,7 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() {
|
||||
false,
|
||||
"",
|
||||
func() {
|
||||
_, err := CreateGrant(val, []string{
|
||||
_, err := authzclitestutil.CreateGrant(val.ClientCtx, []string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()),
|
||||
|
||||
@ -5,13 +5,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestQueryAuthorizations() {
|
||||
@ -20,8 +19,8 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -47,7 +46,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
"invalid grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"decoding bech32 failed: invalid character in string: ' '",
|
||||
@ -57,7 +56,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() {
|
||||
[]string{
|
||||
"invalid granter",
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"decoding bech32 failed: invalid character in string: ' '",
|
||||
@ -67,7 +66,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
``,
|
||||
@ -99,8 +98,8 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -127,7 +126,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||
val.Address.String(),
|
||||
"invalid grantee",
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"",
|
||||
@ -138,7 +137,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||
"invalid granter",
|
||||
grantee.String(),
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"",
|
||||
@ -149,7 +148,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||
val.Address.String(),
|
||||
grantee.String(),
|
||||
"typeMsgSend",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"",
|
||||
@ -160,7 +159,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||
val.Address.String(),
|
||||
grantee.String(),
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"stake","amount":"100"}],"allow_list":[]}`,
|
||||
@ -171,7 +170,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() {
|
||||
val.Address.String(),
|
||||
s.grantee[3].String(),
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
fmt.Sprintf(`{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"stake","amount":"88"}],"allow_list":["%s"]}`, s.grantee[4]),
|
||||
@ -210,7 +209,7 @@ func (s *IntegrationTestSuite) TestQueryGranterGrants() {
|
||||
"invalid address",
|
||||
[]string{
|
||||
"invalid-address",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"decoding bech32 failed",
|
||||
@ -220,7 +219,7 @@ func (s *IntegrationTestSuite) TestQueryGranterGrants() {
|
||||
"no authorization found",
|
||||
[]string{
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"",
|
||||
@ -230,7 +229,7 @@ func (s *IntegrationTestSuite) TestQueryGranterGrants() {
|
||||
"valid case",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"",
|
||||
@ -241,7 +240,7 @@ func (s *IntegrationTestSuite) TestQueryGranterGrants() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
"--limit=2",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"",
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
@ -18,6 +17,7 @@ import (
|
||||
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
|
||||
@ -66,7 +66,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.msgSendExec(s.grantee[1])
|
||||
|
||||
// grant send authorization to grantee2
|
||||
out, err := CreateGrant(val, []string{
|
||||
out, err := authzclitestutil.CreateGrant(val.ClientCtx, []string{
|
||||
s.grantee[1].String(),
|
||||
"send",
|
||||
fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit),
|
||||
@ -86,7 +86,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.grantee[2] = s.createAccount("grantee3")
|
||||
|
||||
// grant send authorization to grantee3
|
||||
_, err = CreateGrant(val, []string{
|
||||
_, err = authzclitestutil.CreateGrant(val.ClientCtx, []string{
|
||||
s.grantee[2].String(),
|
||||
"send",
|
||||
fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit),
|
||||
@ -107,8 +107,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.grantee[5] = s.createAccount("grantee6")
|
||||
|
||||
// grant send authorization with allow list to grantee4
|
||||
out, err = CreateGrant(
|
||||
val,
|
||||
out, err = authzclitestutil.CreateGrant(val.ClientCtx,
|
||||
[]string{
|
||||
s.grantee[3].String(),
|
||||
"send",
|
||||
@ -513,10 +512,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
out, err := CreateGrant(
|
||||
val,
|
||||
tc.args,
|
||||
)
|
||||
out, err := authzclitestutil.CreateGrant(val.ClientCtx, tc.args)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err, out)
|
||||
s.Require().Contains(err.Error(), tc.expErrMsg)
|
||||
@ -543,8 +539,8 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() {
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
// send-authorization
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -560,8 +556,8 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// generic-authorization
|
||||
_, err = CreateGrant(
|
||||
val,
|
||||
_, err = authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -577,8 +573,8 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// generic-authorization used for amino testing
|
||||
_, err = CreateGrant(
|
||||
val,
|
||||
_, err = authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -691,8 +687,8 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() {
|
||||
grantee := s.grantee[0]
|
||||
tenSeconds := time.Now().Add(time.Second * time.Duration(10)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -734,8 +730,8 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -838,8 +834,8 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() {
|
||||
grantee1 := s.grantee[2]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -950,8 +946,8 @@ func (s *IntegrationTestSuite) TestExecSendAuthzWithAllowList() {
|
||||
notAllowedAddr := s.grantee[5]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -1028,7 +1024,7 @@ func (s *IntegrationTestSuite) TestExecSendAuthzWithAllowList() {
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
// query tx and check result
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{response.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{response.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err)
|
||||
s.Contains(out.String(), fmt.Sprintf("cannot send to %s address", notAllowedAddr))
|
||||
}
|
||||
@ -1038,8 +1034,8 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"delegate",
|
||||
@ -1132,8 +1128,8 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||
}
|
||||
|
||||
// test delegate no spend-limit
|
||||
_, err = CreateGrant(
|
||||
val,
|
||||
_, err = authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"delegate",
|
||||
@ -1212,8 +1208,8 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||
}
|
||||
|
||||
// test delegating to denied validator
|
||||
_, err = CreateGrant(
|
||||
val,
|
||||
_, err = authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"delegate",
|
||||
@ -1245,7 +1241,7 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() {
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String())
|
||||
|
||||
// query tx and check result
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{response.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, authcli.QueryTxCmd(), []string{response.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err)
|
||||
s.Contains(out.String(), fmt.Sprintf("cannot delegate/undelegate to %s validator", val.ValAddress.String()))
|
||||
}
|
||||
@ -1256,8 +1252,8 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
// granting undelegate msg authorization
|
||||
_, err := CreateGrant(
|
||||
val,
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"unbond",
|
||||
@ -1367,8 +1363,8 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() {
|
||||
}
|
||||
|
||||
// grant undelegate authorization without limit
|
||||
_, err = CreateGrant(
|
||||
val,
|
||||
_, err = authzclitestutil.CreateGrant(
|
||||
val.ClientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"unbond",
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -111,7 +110,7 @@ func (s *EndToEndTestSuite) TestGetBalancesCmd() {
|
||||
"total account balance",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -128,7 +127,7 @@ func (s *EndToEndTestSuite) TestGetBalancesCmd() {
|
||||
"total account balance of a specific denom",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=%s", cli.FlagDenom, s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
@ -141,7 +140,7 @@ func (s *EndToEndTestSuite) TestGetBalancesCmd() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=foobar", cli.FlagDenom),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
&sdk.Coin{},
|
||||
@ -181,7 +180,7 @@ func (s *EndToEndTestSuite) TestGetCmdQueryTotalSupply() {
|
||||
name: "total supply",
|
||||
args: []string{
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
respType: &types.QueryTotalSupplyResponse{},
|
||||
expected: &types.QueryTotalSupplyResponse{
|
||||
@ -197,7 +196,7 @@ func (s *EndToEndTestSuite) TestGetCmdQueryTotalSupply() {
|
||||
args: []string{
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
fmt.Sprintf("--%s=%s", cli.FlagDenom, s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
respType: &sdk.Coin{},
|
||||
expected: &sdk.Coin{
|
||||
@ -210,7 +209,7 @@ func (s *EndToEndTestSuite) TestGetCmdQueryTotalSupply() {
|
||||
args: []string{
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
fmt.Sprintf("--%s=foobar", cli.FlagDenom),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
respType: &sdk.Coin{},
|
||||
expected: &sdk.Coin{
|
||||
@ -253,7 +252,7 @@ func (s *EndToEndTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
name: "all denoms client metadata",
|
||||
args: []string{
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
respType: &types.QueryDenomsMetadataResponse{},
|
||||
expected: &types.QueryDenomsMetadataResponse{
|
||||
@ -305,7 +304,7 @@ func (s *EndToEndTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
args: []string{
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
fmt.Sprintf("--%s=%s", cli.FlagDenom, "uatom"),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
respType: &types.QueryDenomMetadataResponse{},
|
||||
expected: &types.QueryDenomMetadataResponse{
|
||||
@ -335,7 +334,7 @@ func (s *EndToEndTestSuite) TestGetCmdQueryDenomsMetadata() {
|
||||
args: []string{
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
fmt.Sprintf("--%s=foobar", cli.FlagDenom),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
expectErr: true,
|
||||
respType: &types.QueryDenomMetadataResponse{},
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
@ -81,12 +80,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"community_tax":"0.020000000000000000","base_proposer_reward":"0.010000000000000000","bonus_proposer_reward":"0.040000000000000000","withdraw_addr_enabled":true}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`base_proposer_reward: "0.010000000000000000"
|
||||
bonus_proposer_reward: "0.040000000000000000"
|
||||
community_tax: "0.020000000000000000"
|
||||
@ -118,17 +117,17 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorDistributionInfo() {
|
||||
}{
|
||||
{
|
||||
"invalid val address",
|
||||
[]string{"invalid address", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"invalid address", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"json output",
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -176,7 +175,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val.Address).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"rewards":[{"denom":"stake","amount":"232.260000000000000000"}]}`,
|
||||
@ -184,7 +183,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val.Address).String(),
|
||||
},
|
||||
@ -239,7 +238,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val.Address).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"commission":[{"denom":"stake","amount":"116.130000000000000000"}]}`,
|
||||
@ -247,7 +246,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorCommission() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val.Address).String(),
|
||||
},
|
||||
@ -320,7 +319,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorSlashes() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val.Address).String(), "1", "3",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"{\"slashes\":[],\"pagination\":{\"next_key\":null,\"total\":\"0\"}}",
|
||||
@ -328,7 +327,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorSlashes() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val.Address).String(), "1", "3",
|
||||
},
|
||||
@ -392,7 +391,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
fmt.Sprintf(`{"rewards":[{"validator_address":"%s","reward":[{"denom":"stake","amount":"193.550000000000000000"}]}],"total":[{"denom":"stake","amount":"193.550000000000000000"}]}`, valAddr.String()),
|
||||
@ -402,7 +401,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(), valAddr.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"rewards":[{"denom":"stake","amount":"193.550000000000000000"}]}`,
|
||||
@ -410,7 +409,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(),
|
||||
},
|
||||
@ -427,7 +426,7 @@ total:
|
||||
{
|
||||
"text output (specific validator)",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(), valAddr.String(),
|
||||
},
|
||||
@ -469,12 +468,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryCommunityPool() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"pool":[{"denom":"stake","amount":"4.740000000000000000"}]}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag), fmt.Sprintf("--%s=3", flags.FlagHeight)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput), fmt.Sprintf("--%s=3", flags.FlagHeight)},
|
||||
`pool:
|
||||
- amount: "4.740000000000000000"
|
||||
denom: stake`,
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
@ -130,7 +129,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() {
|
||||
[]string{
|
||||
"wrong_granter",
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"decoding bech32 failed",
|
||||
true, nil, nil,
|
||||
@ -140,7 +139,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() {
|
||||
[]string{
|
||||
granter.String(),
|
||||
"wrong_grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"decoding bech32 failed",
|
||||
true, nil, nil,
|
||||
@ -150,7 +149,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() {
|
||||
[]string{
|
||||
"cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl",
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"fee-grant not found",
|
||||
true, nil, nil,
|
||||
@ -160,7 +159,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrant() {
|
||||
[]string{
|
||||
granter.String(),
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"",
|
||||
false,
|
||||
@ -213,7 +212,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() {
|
||||
"wrong grantee",
|
||||
[]string{
|
||||
"wrong_grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil, 0,
|
||||
},
|
||||
@ -221,7 +220,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() {
|
||||
"non existent grantee",
|
||||
[]string{
|
||||
"cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, &feegrant.QueryAllowancesResponse{}, 0,
|
||||
},
|
||||
@ -229,7 +228,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGrantee() {
|
||||
"valid req",
|
||||
[]string{
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, &feegrant.QueryAllowancesResponse{}, 1,
|
||||
},
|
||||
@ -270,7 +269,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGranter() {
|
||||
"wrong grantee",
|
||||
[]string{
|
||||
"wrong_grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil, 0,
|
||||
},
|
||||
@ -278,7 +277,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGranter() {
|
||||
"non existent grantee",
|
||||
[]string{
|
||||
"cosmos1nph3cfzk6trsmfxkeu943nvach5qw4vwstnvkl",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, &feegrant.QueryAllowancesByGranterResponse{}, 0,
|
||||
},
|
||||
@ -286,7 +285,7 @@ func (s *IntegrationTestSuite) TestCmdGetFeeGrantsByGranter() {
|
||||
"valid req",
|
||||
[]string{
|
||||
granter.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, &feegrant.QueryAllowancesByGranterResponse{}, 1,
|
||||
},
|
||||
@ -898,7 +897,7 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
|
||||
args := []string{
|
||||
granter.String(),
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
}
|
||||
|
||||
// get filtered fee allowance and check info
|
||||
|
||||
@ -5,8 +5,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -139,7 +139,7 @@ func (s *DepositTestSuite) TestQueryProposalAfterVotingPeriod() {
|
||||
proposalID := s.proposalIDs[2]
|
||||
|
||||
// query proposal
|
||||
args := []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
args := []string{proposalID, fmt.Sprintf("--%s=json", flags.FlagOutput)}
|
||||
cmd := cli.GetCmdQueryProposal()
|
||||
_, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
s.Require().NoError(err)
|
||||
@ -158,7 +158,7 @@ func (s *DepositTestSuite) TestQueryProposalAfterVotingPeriod() {
|
||||
}
|
||||
|
||||
func (s *DepositTestSuite) queryDeposits(val *network.Validator, proposalID string, exceptErr bool, message string) *v1.QueryDepositsResponse {
|
||||
args := []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
args := []string{proposalID, fmt.Sprintf("--%s=json", flags.FlagOutput)}
|
||||
var depositsRes *v1.QueryDepositsResponse
|
||||
cmd := cli.GetCmdQueryDeposits()
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
@ -175,7 +175,7 @@ func (s *DepositTestSuite) queryDeposits(val *network.Validator, proposalID stri
|
||||
}
|
||||
|
||||
func (s *DepositTestSuite) queryDeposit(val *network.Validator, proposalID string, exceptErr bool, message string) *v1.Deposit {
|
||||
args := []string{proposalID, val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
args := []string{proposalID, val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)}
|
||||
var depositRes *v1.Deposit
|
||||
cmd := cli.GetCmdQueryDeposit()
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
|
||||
@ -4,8 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
@ -23,7 +22,7 @@ func (s *IntegrationTestSuite) TestCmdParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"voting_params":{"voting_period":"172800s"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800s","voting_period":"172800s","quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000","min_initial_deposit_ratio":"0.000000000000000000"}}`,
|
||||
},
|
||||
{
|
||||
@ -81,7 +80,7 @@ func (s *IntegrationTestSuite) TestCmdParam() {
|
||||
"voting params",
|
||||
[]string{
|
||||
"voting",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`{"voting_period":"172800000000000"}`,
|
||||
},
|
||||
@ -89,7 +88,7 @@ func (s *IntegrationTestSuite) TestCmdParam() {
|
||||
"tally params",
|
||||
[]string{
|
||||
"tallying",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"}`,
|
||||
},
|
||||
@ -97,7 +96,7 @@ func (s *IntegrationTestSuite) TestCmdParam() {
|
||||
"deposit params",
|
||||
[]string{
|
||||
"deposit",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}`,
|
||||
},
|
||||
@ -129,7 +128,7 @@ func (s *IntegrationTestSuite) TestCmdProposer() {
|
||||
{
|
||||
"without proposal id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
``,
|
||||
@ -138,7 +137,7 @@ func (s *IntegrationTestSuite) TestCmdProposer() {
|
||||
"json output",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
fmt.Sprintf("{\"proposal_id\":\"%s\",\"proposer\":\"%s\"}", "1", val.Address.String()),
|
||||
@ -175,7 +174,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
|
||||
{
|
||||
"without proposal id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
v1.TallyResult{},
|
||||
@ -184,7 +183,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
|
||||
"json output",
|
||||
[]string{
|
||||
"2",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
v1.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)),
|
||||
@ -193,7 +192,7 @@ func (s *IntegrationTestSuite) TestCmdTally() {
|
||||
"json output",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
v1.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)),
|
||||
@ -233,7 +232,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposal() {
|
||||
"get non existing proposal",
|
||||
[]string{
|
||||
"10",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -241,7 +240,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposal() {
|
||||
"get proposal with json response",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -278,7 +277,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposals() {
|
||||
{
|
||||
"get proposals as json response",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -286,7 +285,7 @@ func (s *IntegrationTestSuite) TestCmdGetProposals() {
|
||||
"get proposals with invalid status",
|
||||
[]string{
|
||||
"--status=unknown",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -332,7 +331,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposits() {
|
||||
"get deposits(valid req)",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -388,7 +387,7 @@ func (s *IntegrationTestSuite) TestCmdQueryDeposit() {
|
||||
[]string{
|
||||
"1",
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -439,7 +438,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVotes() {
|
||||
"vote for invalid proposal",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -498,7 +497,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
|
||||
[]string{
|
||||
"1",
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
v1.NewNonSplitVoteOption(v1.OptionYes),
|
||||
@ -508,7 +507,7 @@ func (s *IntegrationTestSuite) TestCmdQueryVote() {
|
||||
[]string{
|
||||
"3",
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
v1.WeightedVoteOptions{
|
||||
|
||||
@ -10,8 +10,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/group"
|
||||
client "github.com/cosmos/cosmos-sdk/x/group/client/cli"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
)
|
||||
|
||||
func (s *IntegrationTestSuite) TestQueryGroupInfo() {
|
||||
@ -27,21 +25,21 @@ func (s *IntegrationTestSuite) TestQueryGroupInfo() {
|
||||
}{
|
||||
{
|
||||
"group not found",
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"group: not found",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"group id invalid",
|
||||
[]string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"strconv.ParseUint: parsing \"\": invalid syntax",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"group found",
|
||||
[]string{strconv.FormatUint(s.group.Id, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{strconv.FormatUint(s.group.Id, 10), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -78,7 +76,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
|
||||
require := s.Require()
|
||||
|
||||
cmd := client.QueryGroupsByAdminCmd()
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
require.NoError(err)
|
||||
|
||||
var groups group.QueryGroupsByAdminResponse
|
||||
@ -86,7 +84,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
|
||||
require.Len(groups.Groups, 1)
|
||||
|
||||
cmd = client.QueryGroupMembersCmd()
|
||||
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{fmt.Sprintf("%d", groups.Groups[0].Id), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{fmt.Sprintf("%d", groups.Groups[0].Id), fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
require.NoError(err)
|
||||
|
||||
var members group.QueryGroupMembersResponse
|
||||
@ -105,7 +103,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
|
||||
}{
|
||||
{
|
||||
"invalid address",
|
||||
[]string{"abcd", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"abcd", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"invalid bech32 string",
|
||||
0,
|
||||
@ -113,7 +111,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
|
||||
},
|
||||
{
|
||||
"not part of any group",
|
||||
[]string{testAddr.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{testAddr.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -121,7 +119,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByMembers() {
|
||||
},
|
||||
{
|
||||
"expect one group",
|
||||
[]string{members.Members[0].Member.Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{members.Members[0].Member.Address, fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
1,
|
||||
@ -163,7 +161,7 @@ func (s *IntegrationTestSuite) TestQueryGroupMembers() {
|
||||
}{
|
||||
{
|
||||
"no group",
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -171,7 +169,7 @@ func (s *IntegrationTestSuite) TestQueryGroupMembers() {
|
||||
},
|
||||
{
|
||||
"members found",
|
||||
[]string{strconv.FormatUint(s.group.Id, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{strconv.FormatUint(s.group.Id, 10), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -236,7 +234,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByAdmin() {
|
||||
},
|
||||
{
|
||||
"no group",
|
||||
[]string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -244,7 +242,7 @@ func (s *IntegrationTestSuite) TestQueryGroupsByAdmin() {
|
||||
},
|
||||
{
|
||||
"found groups",
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -294,14 +292,14 @@ func (s *IntegrationTestSuite) TestQueryGroupPolicyInfo() {
|
||||
}{
|
||||
{
|
||||
"group policy not found",
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"group policy: not found",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"group policy found",
|
||||
[]string{s.groupPolicies[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{s.groupPolicies[0].Address, fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -359,7 +357,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByGroup() {
|
||||
},
|
||||
{
|
||||
"no group policy",
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -367,7 +365,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByGroup() {
|
||||
},
|
||||
{
|
||||
"found group policies",
|
||||
[]string{strconv.FormatUint(s.group.Id, 10), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{strconv.FormatUint(s.group.Id, 10), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -435,7 +433,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByAdmin() {
|
||||
},
|
||||
{
|
||||
"no group policy",
|
||||
[]string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -443,7 +441,7 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByAdmin() {
|
||||
},
|
||||
{
|
||||
"found group policies",
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -502,14 +500,14 @@ func (s *IntegrationTestSuite) TestQueryProposal() {
|
||||
}{
|
||||
{
|
||||
"not found",
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"not found",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"invalid proposal id",
|
||||
[]string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"strconv.ParseUint: parsing \"\": invalid syntax",
|
||||
0,
|
||||
@ -554,7 +552,7 @@ func (s *IntegrationTestSuite) TestQueryProposalsByGroupPolicy() {
|
||||
},
|
||||
{
|
||||
"no group policy",
|
||||
[]string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -562,7 +560,7 @@ func (s *IntegrationTestSuite) TestQueryProposalsByGroupPolicy() {
|
||||
},
|
||||
{
|
||||
"found proposals",
|
||||
[]string{s.groupPolicies[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{s.groupPolicies[0].Address, fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -608,14 +606,14 @@ func (s *IntegrationTestSuite) TestQueryVoteByProposalVoter() {
|
||||
}{
|
||||
{
|
||||
"invalid voter address",
|
||||
[]string{"1", "invalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"1", "invalid", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"decoding bech32 failed: invalid bech32",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"invalid proposal id",
|
||||
[]string{"", val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"", val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"strconv.ParseUint: parsing \"\": invalid syntax",
|
||||
0,
|
||||
@ -652,7 +650,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByProposal() {
|
||||
}{
|
||||
{
|
||||
"invalid proposal id",
|
||||
[]string{"", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"strconv.ParseUint: parsing \"\": invalid syntax",
|
||||
0,
|
||||
@ -660,7 +658,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByProposal() {
|
||||
},
|
||||
{
|
||||
"no votes",
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"12345", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -668,7 +666,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByProposal() {
|
||||
},
|
||||
{
|
||||
"found votes",
|
||||
[]string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -715,7 +713,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByVoter() {
|
||||
}{
|
||||
{
|
||||
"invalid voter address",
|
||||
[]string{"abcd", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"abcd", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"decoding bech32 failed: invalid bech32",
|
||||
0,
|
||||
@ -723,7 +721,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByVoter() {
|
||||
},
|
||||
{
|
||||
"no votes",
|
||||
[]string{s.groupPolicies[0].Address, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{s.groupPolicies[0].Address, fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
"",
|
||||
0,
|
||||
@ -731,7 +729,7 @@ func (s *IntegrationTestSuite) TestQueryVotesByVoter() {
|
||||
},
|
||||
{
|
||||
"found votes",
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
"",
|
||||
0,
|
||||
@ -810,7 +808,7 @@ func (s *IntegrationTestSuite) TestTallyResult() {
|
||||
"not found",
|
||||
[]string{
|
||||
"12345",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
group.TallyResult{},
|
||||
@ -821,7 +819,7 @@ func (s *IntegrationTestSuite) TestTallyResult() {
|
||||
"invalid proposal id",
|
||||
[]string{
|
||||
"",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
group.TallyResult{},
|
||||
@ -832,7 +830,7 @@ func (s *IntegrationTestSuite) TestTallyResult() {
|
||||
"valid proposal id with no votes",
|
||||
[]string{
|
||||
proposalID,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
group.DefaultTallyResult(),
|
||||
@ -843,7 +841,7 @@ func (s *IntegrationTestSuite) TestTallyResult() {
|
||||
"valid proposal id",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
group.TallyResult{
|
||||
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||
@ -121,7 +120,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
}
|
||||
|
||||
s.createGroupThresholdPolicyWithBalance(val.Address.String(), "1", threshold, 1000)
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err, out.String())
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
}
|
||||
@ -142,7 +141,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().NoError(clitestutil.CheckTxCode(s.network, val.ClientCtx, txResp.TxHash, 0))
|
||||
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err, out.String())
|
||||
|
||||
var res group.QueryGroupPoliciesByGroupResponse
|
||||
@ -182,14 +181,14 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().NoError(clitestutil.CheckTxCode(s.network, val.ClientCtx, txResp.TxHash, 0))
|
||||
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryProposalCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryProposalCmd(), []string{"1", fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err, out.String())
|
||||
|
||||
var proposalRes group.QueryProposalResponse
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposalRes))
|
||||
s.proposal = proposalRes.Proposal
|
||||
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryVoteByProposalVoterCmd(), []string{"1", val.Address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryVoteByProposalVoterCmd(), []string{"1", val.Address.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err, out.String())
|
||||
|
||||
var voteRes group.QueryVoteByProposalVoterResponse
|
||||
@ -2174,7 +2173,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() {
|
||||
s.Require().NoError(err, out.String())
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
out, err = clitestutil.ExecTestCLICmd(clientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{groupID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(clientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{groupID, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err, out.String())
|
||||
s.Require().NotNil(out)
|
||||
var resp group.QueryGroupPoliciesByGroupResponse
|
||||
@ -2611,7 +2610,7 @@ func (s *IntegrationTestSuite) createGroupThresholdPolicyWithBalance(adminAddres
|
||||
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String())
|
||||
s.Require().NoError(clitestutil.CheckTxCode(s.network, val.ClientCtx, txResp.TxHash, 0))
|
||||
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{groupID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{groupID, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
s.Require().NoError(err, out.String())
|
||||
|
||||
var res group.QueryGroupPoliciesByGroupResponse
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
@ -65,12 +64,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"mint_denom":"stake","inflation_rate_change":"0.130000000000000000","inflation_max":"1.000000000000000000","inflation_min":"1.000000000000000000","goal_bonded":"0.670000000000000000","blocks_per_year":"6311520"}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`blocks_per_year: "6311520"
|
||||
goal_bonded: "0.670000000000000000"
|
||||
inflation_max: "1.000000000000000000"
|
||||
@ -104,12 +103,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryInflation() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`1.000000000000000000`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`1.000000000000000000`,
|
||||
},
|
||||
}
|
||||
@ -138,12 +137,12 @@ func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`500000000.000000000000000000`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`500000000.000000000000000000`,
|
||||
},
|
||||
}
|
||||
|
||||
@ -3,8 +3,7 @@ package nft
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
@ -20,14 +19,14 @@ func ExecQueryClass(val *network.Validator, classID string) (testutil.BufferWrit
|
||||
cmd := cli.GetCmdQueryClass()
|
||||
var args []string
|
||||
args = append(args, classID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
func ExecQueryClasses(val *network.Validator) (testutil.BufferWriter, error) {
|
||||
cmd := cli.GetCmdQueryClasses()
|
||||
var args []string
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
@ -36,7 +35,7 @@ func ExecQueryNFT(val *network.Validator, classID, nftID string) (testutil.Buffe
|
||||
var args []string
|
||||
args = append(args, classID)
|
||||
args = append(args, nftID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
@ -45,7 +44,7 @@ func ExecQueryNFTs(val *network.Validator, classID, owner string) (testutil.Buff
|
||||
var args []string
|
||||
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagClassID, classID))
|
||||
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagOwner, owner))
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
@ -54,7 +53,7 @@ func ExecQueryOwner(val *network.Validator, classID, nftID string) (testutil.Buf
|
||||
var args []string
|
||||
args = append(args, classID)
|
||||
args = append(args, nftID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
@ -63,7 +62,7 @@ func ExecQueryBalance(val *network.Validator, classID, owner string) (testutil.B
|
||||
var args []string
|
||||
args = append(args, owner)
|
||||
args = append(args, classID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
@ -71,6 +70,6 @@ func ExecQuerySupply(val *network.Validator, classID string) (testutil.BufferWri
|
||||
cmd := cli.GetCmdQuerySupply()
|
||||
var args []string
|
||||
args = append(args, classID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
return clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args)
|
||||
}
|
||||
|
||||
@ -6,7 +6,6 @@ import (
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
@ -63,7 +62,7 @@ func (s *EndToEndTestSuite) TestGetCmdQuerySigningInfo() {
|
||||
"valid address (json output)",
|
||||
[]string{
|
||||
pubKeyStr,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -73,7 +72,7 @@ func (s *EndToEndTestSuite) TestGetCmdQuerySigningInfo() {
|
||||
"valid address (text output)",
|
||||
[]string{
|
||||
pubKeyStr,
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -114,12 +113,12 @@ func (s *EndToEndTestSuite) TestGetCmdQueryParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"signed_blocks_window":"100","min_signed_per_window":"0.500000000000000000","downtime_jail_duration":"600s","slash_fraction_double_sign":"0.050000000000000000","slash_fraction_downtime":"0.010000000000000000"}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`downtime_jail_duration: 600s
|
||||
min_signed_per_window: "0.500000000000000000"
|
||||
signed_blocks_window: "100"
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"github.com/tendermint/tendermint/proto/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/rpc/client/http"
|
||||
|
||||
@ -255,17 +254,17 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidator() {
|
||||
}{
|
||||
{
|
||||
"with invalid address ",
|
||||
[]string{"somethinginvalidaddress", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"somethinginvalidaddress", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"with valid and not existing address",
|
||||
[]string{"cosmosvaloper15jkng8hytwt22lllv6mw4k89qkqehtahd84ptu", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"cosmosvaloper15jkng8hytwt22lllv6mw4k89qkqehtahd84ptu", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"happy case",
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -298,14 +297,14 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidators() {
|
||||
{
|
||||
"one validator case",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagLimit),
|
||||
},
|
||||
1,
|
||||
},
|
||||
{
|
||||
"multi validator case",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
len(s.network.Validators),
|
||||
},
|
||||
}
|
||||
@ -343,7 +342,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() {
|
||||
[]string{
|
||||
"wrongDelAddr",
|
||||
val2.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil, nil,
|
||||
},
|
||||
@ -352,7 +351,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil, nil,
|
||||
},
|
||||
@ -361,7 +360,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegation() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
val2.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
&types.DelegationResponse{},
|
||||
@ -418,7 +417,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryDelegations() {
|
||||
"valid request (height specific)",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -474,7 +473,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorDelegations() {
|
||||
"valid request(height specific)",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -518,7 +517,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegations() {
|
||||
"wrong delegator address",
|
||||
[]string{
|
||||
"wrongDelAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -526,7 +525,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -567,7 +566,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegation() {
|
||||
[]string{
|
||||
"wrongDelAddr",
|
||||
val.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -576,7 +575,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegation() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -585,7 +584,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegation() {
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
val.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -626,7 +625,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorUnbondingDelegations() {
|
||||
"wrong validator address",
|
||||
[]string{
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -634,7 +633,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorUnbondingDelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
val.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -675,7 +674,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegations() {
|
||||
"wrong delegator address",
|
||||
[]string{
|
||||
"wrongdeladdr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -683,7 +682,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
val.Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -729,7 +728,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() {
|
||||
"wrongdeladdr",
|
||||
val.ValAddress.String(),
|
||||
val2.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -739,7 +738,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() {
|
||||
val.Address.String(),
|
||||
"wrongSrcValAddress",
|
||||
val2.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -749,7 +748,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() {
|
||||
val.Address.String(),
|
||||
val.ValAddress.String(),
|
||||
"wrongDestValAddress",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -759,7 +758,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryRedelegation() {
|
||||
val.Address.String(),
|
||||
val.ValAddress.String(),
|
||||
val2.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -803,7 +802,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorRedelegations() {
|
||||
"wrong validator address",
|
||||
[]string{
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -811,7 +810,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryValidatorRedelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
val.ValAddress.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -854,7 +853,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryHistoricalInfo() {
|
||||
"wrong height",
|
||||
[]string{
|
||||
"-1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -862,7 +861,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryHistoricalInfo() {
|
||||
"valid request",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -897,7 +896,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
|
||||
}{
|
||||
{
|
||||
"with text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`bond_denom: stake
|
||||
historical_entries: 10000
|
||||
max_entries: 7
|
||||
@ -907,7 +906,7 @@ unbonding_time: 1814400s`,
|
||||
},
|
||||
{
|
||||
"with json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"unbonding_time":"1814400s","max_validators":100,"max_entries":7,"historical_entries":10000,"bond_denom":"stake","min_commission_rate":"0.000000000000000000"}`,
|
||||
},
|
||||
}
|
||||
@ -933,7 +932,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryPool() {
|
||||
{
|
||||
"with text",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
fmt.Sprintf(`bonded_tokens: "%s"
|
||||
@ -942,7 +941,7 @@ not_bonded_tokens: "0"`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()),
|
||||
{
|
||||
"with json",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
fmt.Sprintf(`{"not_bonded_tokens":"0","bonded_tokens":"%s"}`, cli.DefaultTokens.Mul(sdk.NewInt(2)).String()),
|
||||
@ -1530,7 +1529,7 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() {
|
||||
queryCmd := cli.GetCmdQueryValidator()
|
||||
res, err := clitestutil.ExecTestCLICmd(
|
||||
val.ClientCtx, queryCmd,
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
)
|
||||
require.NoError(err)
|
||||
var result types.Validator
|
||||
@ -1550,7 +1549,7 @@ func (s *IntegrationTestSuite) TestEditValidatorMoniker() {
|
||||
|
||||
res, err = clitestutil.ExecTestCLICmd(
|
||||
val.ClientCtx, queryCmd,
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.ValAddress.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
)
|
||||
require.NoError(err)
|
||||
require.NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &result))
|
||||
|
||||
@ -3,9 +3,8 @@ package cli
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authcli "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||
@ -22,7 +21,7 @@ func CheckTxCode(network *network.Network, clientCtx client.Context, txHash stri
|
||||
}
|
||||
|
||||
cmd := authcli.QueryTxCmd()
|
||||
out, err := ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err := ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -50,7 +49,7 @@ func GetTxResponse(network *network.Network, clientCtx client.Context, txHash st
|
||||
}
|
||||
|
||||
cmd := authcli.QueryTxCmd()
|
||||
out, err := ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)})
|
||||
out, err := ExecTestCLICmd(clientCtx, cmd, []string{txHash, fmt.Sprintf("--%s=json", flags.FlagOutput)})
|
||||
if err != nil {
|
||||
return sdk.TxResponse{}, err
|
||||
}
|
||||
|
||||
@ -11,7 +11,6 @@ import (
|
||||
"cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -190,18 +189,18 @@ func (s *CLITestSuite) TestCLIQueryTxCmdByHash() {
|
||||
},
|
||||
{
|
||||
"with invalid hash",
|
||||
[]string{"somethinginvalid", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"somethinginvalid", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`[somethinginvalid --output=json]`,
|
||||
},
|
||||
{
|
||||
"with valid and not existing hash",
|
||||
[]string{"C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`[C7E7D3A86A17AB3A321172239F3B61357937AF0F25D9FA4D2F4DCCAD9B0D7747 --output=json`,
|
||||
},
|
||||
{
|
||||
"happy case",
|
||||
[]string{txRes.TxHash, fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
fmt.Sprintf("%s --%s=json", txRes.TxHash, tmcli.OutputFlag),
|
||||
[]string{txRes.TxHash, fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
fmt.Sprintf("%s --%s=json", txRes.TxHash, flags.FlagOutput),
|
||||
},
|
||||
}
|
||||
|
||||
@ -229,7 +228,7 @@ func (s *CLITestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
fmt.Sprintf("--type=%s", "foo"),
|
||||
"bar",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--type=foo bar --output=json",
|
||||
},
|
||||
@ -238,7 +237,7 @@ func (s *CLITestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=acc_seq",
|
||||
"",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--type=acc_seq --output=json",
|
||||
},
|
||||
@ -247,7 +246,7 @@ func (s *CLITestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=acc_seq",
|
||||
"foobar",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--type=acc_seq foobar --output=json",
|
||||
},
|
||||
@ -256,7 +255,7 @@ func (s *CLITestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=signature",
|
||||
"",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--type=signature --output=json",
|
||||
},
|
||||
@ -265,7 +264,7 @@ func (s *CLITestSuite) TestCLIQueryTxCmdByEvents() {
|
||||
[]string{
|
||||
"--type=signature",
|
||||
"foo",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--type=signature foo --output=json",
|
||||
},
|
||||
@ -295,7 +294,7 @@ func (s *CLITestSuite) TestCLIQueryTxsCmdByEvents() {
|
||||
[]string{
|
||||
fmt.Sprintf("--events=tx.fee=%s",
|
||||
sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10))).String()),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"",
|
||||
},
|
||||
@ -304,7 +303,7 @@ func (s *CLITestSuite) TestCLIQueryTxsCmdByEvents() {
|
||||
[]string{
|
||||
fmt.Sprintf("--events=tx.fee=%s",
|
||||
sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(0))).String()),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"",
|
||||
},
|
||||
@ -811,12 +810,12 @@ func (s *CLITestSuite) TestQueryParamsCmd() {
|
||||
}{
|
||||
{
|
||||
"happy case",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"with specific height",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
@ -91,4 +91,24 @@ func TxAuxToFeeExec(clientCtx client.Context, filename string, extraArgs ...stri
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAuxToFeeCommand(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func QueryAccountExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{address.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetAccountCmd(), append(args, extraArgs...))
|
||||
}
|
||||
|
||||
func TxMultiSignBatchExec(clientCtx client.Context, filename string, from string, sigFile1 string, sigFile2 string, extraArgs ...string) (testutil.BufferWriter, error) {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagKeyringBackend, keyring.BackendTest),
|
||||
filename,
|
||||
from,
|
||||
sigFile1,
|
||||
sigFile2,
|
||||
}
|
||||
|
||||
args = append(args, extraArgs...)
|
||||
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cli.GetMultiSignBatchCmd(), args)
|
||||
}
|
||||
|
||||
// DONTCOVER
|
||||
|
||||
@ -4,14 +4,13 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
||||
)
|
||||
|
||||
func (s *CLITestSuite) TestQueryAuthorizations() {
|
||||
@ -20,7 +19,8 @@ func (s *CLITestSuite) TestQueryAuthorizations() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -45,7 +45,7 @@ func (s *CLITestSuite) TestQueryAuthorizations() {
|
||||
[]string{
|
||||
val[0].Address.String(),
|
||||
"invalid grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"decoding bech32 failed: invalid character in string: ' '",
|
||||
@ -55,7 +55,7 @@ func (s *CLITestSuite) TestQueryAuthorizations() {
|
||||
[]string{
|
||||
"invalid granter",
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"decoding bech32 failed: invalid character in string: ' '",
|
||||
@ -65,7 +65,7 @@ func (s *CLITestSuite) TestQueryAuthorizations() {
|
||||
[]string{
|
||||
val[0].Address.String(),
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
``,
|
||||
@ -96,7 +96,8 @@ func (s *CLITestSuite) TestQueryAuthorization() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(
|
||||
s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -121,7 +122,7 @@ func (s *CLITestSuite) TestQueryAuthorization() {
|
||||
val[0].Address.String(),
|
||||
"invalid grantee",
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -131,7 +132,7 @@ func (s *CLITestSuite) TestQueryAuthorization() {
|
||||
"invalid granter",
|
||||
grantee.String(),
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -141,7 +142,7 @@ func (s *CLITestSuite) TestQueryAuthorization() {
|
||||
val[0].Address.String(),
|
||||
grantee.String(),
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -151,7 +152,7 @@ func (s *CLITestSuite) TestQueryAuthorization() {
|
||||
val[0].Address.String(),
|
||||
s.grantee[3].String(),
|
||||
typeMsgSend,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -187,7 +188,7 @@ func (s *CLITestSuite) TestQueryGranterGrants() {
|
||||
"invalid address",
|
||||
[]string{
|
||||
"invalid-address",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
"decoding bech32 failed",
|
||||
@ -196,7 +197,7 @@ func (s *CLITestSuite) TestQueryGranterGrants() {
|
||||
"no authorization found",
|
||||
[]string{
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"",
|
||||
@ -205,7 +206,7 @@ func (s *CLITestSuite) TestQueryGranterGrants() {
|
||||
"valid case",
|
||||
[]string{
|
||||
val[0].Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"",
|
||||
@ -215,7 +216,7 @@ func (s *CLITestSuite) TestQueryGranterGrants() {
|
||||
[]string{
|
||||
val[0].Address.String(),
|
||||
"--limit=2",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"",
|
||||
|
||||
@ -21,11 +21,12 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
authzclitestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
govtestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
|
||||
govclitestutil "github.com/cosmos/cosmos-sdk/x/gov/client/testutil"
|
||||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
@ -85,7 +86,7 @@ func (s *CLITestSuite) SetupSuite() {
|
||||
s.msgSendExec(s.grantee[0])
|
||||
|
||||
// create a proposal with deposit
|
||||
_, err := govtestutil.MsgSubmitLegacyProposal(s.clientCtx, val[0].Address.String(),
|
||||
_, err := govclitestutil.MsgSubmitLegacyProposal(s.clientCtx, val[0].Address.String(),
|
||||
"Text Proposal 1", "Where is the title!?", govv1beta1.ProposalTypeText,
|
||||
fmt.Sprintf("--%s=%s", govcli.FlagDeposit, sdk.NewCoin("stake", govv1.DefaultMinDepositTokens).String()))
|
||||
s.Require().NoError(err)
|
||||
@ -96,7 +97,7 @@ func (s *CLITestSuite) SetupSuite() {
|
||||
s.msgSendExec(s.grantee[1])
|
||||
|
||||
// grant send authorization to grantee2
|
||||
out, err := s.createGrant([]string{
|
||||
out, err := authzclitestutil.CreateGrant(s.clientCtx, []string{
|
||||
s.grantee[1].String(),
|
||||
"send",
|
||||
fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit),
|
||||
@ -115,7 +116,7 @@ func (s *CLITestSuite) SetupSuite() {
|
||||
s.grantee[2] = s.createAccount("grantee3")
|
||||
|
||||
// grant send authorization to grantee3
|
||||
_, err = s.createGrant([]string{
|
||||
_, err = authzclitestutil.CreateGrant(s.clientCtx, []string{
|
||||
s.grantee[2].String(),
|
||||
"send",
|
||||
fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit),
|
||||
@ -135,7 +136,7 @@ func (s *CLITestSuite) SetupSuite() {
|
||||
s.grantee[5] = s.createAccount("grantee6")
|
||||
|
||||
// grant send authorization with allow list to grantee4
|
||||
out, err = s.createGrant(
|
||||
out, err = authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
s.grantee[3].String(),
|
||||
"send",
|
||||
@ -179,11 +180,6 @@ func (s *CLITestSuite) msgSendExec(grantee sdk.AccAddress) {
|
||||
s.Require().Contains(out.String(), `"code":0`)
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) createGrant(args []string) (testutil.BufferWriter, error) {
|
||||
cmd := cli.NewCmdGrantAuthorization()
|
||||
return clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
}
|
||||
|
||||
func (s *CLITestSuite) TestCLITxGrantAuthorization() {
|
||||
val := testutil.CreateKeyringAccounts(s.T(), s.kr, 1)
|
||||
|
||||
@ -429,7 +425,7 @@ func (s *CLITestSuite) TestCLITxGrantAuthorization() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
out, err := s.createGrant(
|
||||
out, err := authzclitestutil.CreateGrant(s.clientCtx,
|
||||
tc.args,
|
||||
)
|
||||
if tc.expectErr {
|
||||
@ -451,7 +447,7 @@ func (s *CLITestSuite) TestCmdRevokeAuthorizations() {
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
// send-authorization
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -466,7 +462,7 @@ func (s *CLITestSuite) TestCmdRevokeAuthorizations() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// generic-authorization
|
||||
_, err = s.createGrant(
|
||||
_, err = authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -481,7 +477,7 @@ func (s *CLITestSuite) TestCmdRevokeAuthorizations() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
// generic-authorization used for amino testing
|
||||
_, err = s.createGrant(
|
||||
_, err = authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -586,7 +582,7 @@ func (s *CLITestSuite) TestExecAuthorizationWithExpiration() {
|
||||
grantee := s.grantee[0]
|
||||
tenSeconds := time.Now().Add(time.Second * time.Duration(10)).Unix()
|
||||
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -626,7 +622,7 @@ func (s *CLITestSuite) TestNewExecGenericAuthorized() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"generic",
|
||||
@ -720,7 +716,7 @@ func (s *CLITestSuite) TestNewExecGrantAuthorized() {
|
||||
grantee := s.grantee[0]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
@ -815,7 +811,7 @@ func (s *CLITestSuite) TestExecSendAuthzWithAllowList() {
|
||||
notAllowedAddr := s.grantee[5]
|
||||
twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix()
|
||||
|
||||
_, err := s.createGrant(
|
||||
_, err := authzclitestutil.CreateGrant(s.clientCtx,
|
||||
[]string{
|
||||
grantee.String(),
|
||||
"send",
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
package authz
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
"github.com/cosmos/cosmos-sdk/x/authz/client/cli"
|
||||
)
|
||||
|
||||
func CreateGrant(val *network.Validator, args []string) (testutil.BufferWriter, error) {
|
||||
func CreateGrant(clientCtx client.Context, args []string) (testutil.BufferWriter, error) {
|
||||
cmd := cli.NewCmdGrantAuthorization()
|
||||
clientCtx := val.ClientCtx
|
||||
return clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
}
|
||||
@ -10,7 +10,6 @@ import (
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -90,12 +89,12 @@ func (s *CLITestSuite) TestGetCmdQueryParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"community_tax":"0","base_proposer_reward":"0","bonus_proposer_reward":"0","withdraw_addr_enabled":false}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`base_proposer_reward: "0"
|
||||
bonus_proposer_reward: "0"
|
||||
community_tax: "0"
|
||||
@ -127,17 +126,17 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorDistributionInfo() {
|
||||
}{
|
||||
{
|
||||
"invalid val address",
|
||||
[]string{"invalid address", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"invalid address", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"json output",
|
||||
[]string{val.String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{val.String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{val.String(), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{val.String(), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -181,7 +180,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val[0].Address).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"rewards":[]}`,
|
||||
@ -189,7 +188,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorOutstandingRewards() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val[0].Address).String(),
|
||||
},
|
||||
@ -238,7 +237,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorCommission() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val[0].Address).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"commission":[]}`,
|
||||
@ -246,7 +245,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorCommission() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val[0].Address).String(),
|
||||
},
|
||||
@ -313,7 +312,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorSlashes() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val[0].Address).String(), "1", "3",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
"{\"slashes\":[],\"pagination\":null}",
|
||||
@ -321,7 +320,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorSlashes() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=3", flags.FlagHeight),
|
||||
sdk.ValAddress(val[0].Address).String(), "1", "3",
|
||||
},
|
||||
@ -381,7 +380,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"rewards":[],"total":[]}`,
|
||||
@ -391,7 +390,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(), valAddr.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
`{"rewards":[]}`,
|
||||
@ -399,7 +398,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegatorRewards() {
|
||||
{
|
||||
"text output",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(),
|
||||
},
|
||||
@ -410,7 +409,7 @@ total: []`,
|
||||
{
|
||||
"text output (specific validator)",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=5", flags.FlagHeight),
|
||||
addr.String(), valAddr.String(),
|
||||
},
|
||||
@ -444,12 +443,12 @@ func (s *CLITestSuite) TestGetCmdQueryCommunityPool() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=3", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`{"pool":[]}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag), fmt.Sprintf("--%s=3", flags.FlagHeight)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput), fmt.Sprintf("--%s=3", flags.FlagHeight)},
|
||||
`pool: []`,
|
||||
},
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@ package cli_test
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/feegrant"
|
||||
"github.com/cosmos/cosmos-sdk/x/feegrant/client/cli"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
)
|
||||
|
||||
func (s *CLITestSuite) TestCmdGetFeeGrant() {
|
||||
@ -26,7 +26,7 @@ func (s *CLITestSuite) TestCmdGetFeeGrant() {
|
||||
[]string{
|
||||
"wrong_granter",
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"decoding bech32 failed",
|
||||
true, nil, nil,
|
||||
@ -36,7 +36,7 @@ func (s *CLITestSuite) TestCmdGetFeeGrant() {
|
||||
[]string{
|
||||
granter.String(),
|
||||
"wrong_grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"decoding bech32 failed",
|
||||
true, nil, nil,
|
||||
@ -76,7 +76,7 @@ func (s *CLITestSuite) TestCmdGetFeeGrantsByGrantee() {
|
||||
"wrong grantee",
|
||||
[]string{
|
||||
"wrong_grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil, 0,
|
||||
},
|
||||
@ -84,7 +84,7 @@ func (s *CLITestSuite) TestCmdGetFeeGrantsByGrantee() {
|
||||
"valid req",
|
||||
[]string{
|
||||
grantee.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, &feegrant.QueryAllowancesResponse{}, 1,
|
||||
},
|
||||
@ -123,7 +123,7 @@ func (s *CLITestSuite) TestCmdGetFeeGrantsByGranter() {
|
||||
"wrong grantee",
|
||||
[]string{
|
||||
"wrong_grantee",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil, 0,
|
||||
},
|
||||
@ -131,7 +131,7 @@ func (s *CLITestSuite) TestCmdGetFeeGrantsByGranter() {
|
||||
"valid req",
|
||||
[]string{
|
||||
granter.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false, &feegrant.QueryAllowancesByGranterResponse{}, 1,
|
||||
},
|
||||
|
||||
@ -4,8 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
)
|
||||
@ -18,7 +17,7 @@ func (s *CLITestSuite) TestCmdParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
"--output=json",
|
||||
},
|
||||
{
|
||||
@ -52,7 +51,7 @@ func (s *CLITestSuite) TestCmdParam() {
|
||||
"voting params",
|
||||
[]string{
|
||||
"voting",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`voting --output=json`,
|
||||
},
|
||||
@ -60,7 +59,7 @@ func (s *CLITestSuite) TestCmdParam() {
|
||||
"tally params",
|
||||
[]string{
|
||||
"tallying",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`tallying --output=json`,
|
||||
},
|
||||
@ -68,7 +67,7 @@ func (s *CLITestSuite) TestCmdParam() {
|
||||
"deposit params",
|
||||
[]string{
|
||||
"deposit",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`deposit --output=json`,
|
||||
},
|
||||
@ -94,7 +93,7 @@ func (s *CLITestSuite) TestCmdProposer() {
|
||||
{
|
||||
"without proposal id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--output=json",
|
||||
},
|
||||
@ -102,7 +101,7 @@ func (s *CLITestSuite) TestCmdProposer() {
|
||||
"json output",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"1 --output=json",
|
||||
},
|
||||
@ -128,7 +127,7 @@ func (s *CLITestSuite) TestCmdTally() {
|
||||
{
|
||||
"without proposal id",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--output=json",
|
||||
},
|
||||
@ -136,7 +135,7 @@ func (s *CLITestSuite) TestCmdTally() {
|
||||
"json output",
|
||||
[]string{
|
||||
"2",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"2 --output=json",
|
||||
},
|
||||
@ -144,7 +143,7 @@ func (s *CLITestSuite) TestCmdTally() {
|
||||
"json output",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"1 --output=json",
|
||||
},
|
||||
@ -171,7 +170,7 @@ func (s *CLITestSuite) TestCmdGetProposal() {
|
||||
"get non existing proposal",
|
||||
[]string{
|
||||
"10",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"10 --output=json",
|
||||
},
|
||||
@ -179,7 +178,7 @@ func (s *CLITestSuite) TestCmdGetProposal() {
|
||||
"get proposal with json response",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"1 --output=json",
|
||||
},
|
||||
@ -205,7 +204,7 @@ func (s *CLITestSuite) TestCmdGetProposals() {
|
||||
{
|
||||
"get proposals as json response",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--output=json",
|
||||
},
|
||||
@ -213,7 +212,7 @@ func (s *CLITestSuite) TestCmdGetProposals() {
|
||||
"get proposals with invalid status",
|
||||
[]string{
|
||||
"--status=unknown",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"--status=unknown --output=json",
|
||||
},
|
||||
@ -247,7 +246,7 @@ func (s *CLITestSuite) TestCmdQueryDeposits() {
|
||||
"get deposits(valid req)",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"1 --output=json",
|
||||
},
|
||||
@ -294,7 +293,7 @@ func (s *CLITestSuite) TestCmdQueryDeposit() {
|
||||
[]string{
|
||||
"1",
|
||||
val[0].Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
fmt.Sprintf("1 %s --output=json", val[0].Address.String()),
|
||||
},
|
||||
@ -335,7 +334,7 @@ func (s *CLITestSuite) TestCmdQueryVotes() {
|
||||
"vote for invalid proposal",
|
||||
[]string{
|
||||
"1",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
"1 --output=json",
|
||||
},
|
||||
@ -383,7 +382,7 @@ func (s *CLITestSuite) TestCmdQueryVote() {
|
||||
[]string{
|
||||
"1",
|
||||
val[0].Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
fmt.Sprintf("1 %s --output=json", val[0].Address.String()),
|
||||
},
|
||||
@ -392,7 +391,7 @@ func (s *CLITestSuite) TestCmdQueryVote() {
|
||||
[]string{
|
||||
"3",
|
||||
val[0].Address.String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
fmt.Sprintf("3 %s --output=json", val[0].Address.String()),
|
||||
},
|
||||
|
||||
@ -19,7 +19,6 @@ import (
|
||||
testutilmod "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
mintcli "github.com/cosmos/cosmos-sdk/x/mint/client/cli"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
)
|
||||
|
||||
func TestGetCmdQueryParams(t *testing.T) {
|
||||
@ -44,13 +43,13 @@ func TestGetCmdQueryParams(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`[--height=1 --output=json]`,
|
||||
`{"mint_denom":"","inflation_rate_change":"0","inflation_max":"0","inflation_min":"0","goal_bonded":"0","blocks_per_year":"0"}`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`[--height=1 --output=text]`,
|
||||
`blocks_per_year: "0"
|
||||
goal_bonded: "0"
|
||||
@ -109,13 +108,13 @@ func TestGetCmdQueryInflation(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`[--height=1 --output=json]`,
|
||||
`<nil>`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`[--height=1 --output=text]`,
|
||||
`<nil>`,
|
||||
},
|
||||
@ -169,13 +168,13 @@ func TestGetCmdQueryAnnualProvisions(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
`[--height=1 --output=json]`,
|
||||
`<nil>`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
`[--height=1 --output=text]`,
|
||||
`<nil>`,
|
||||
},
|
||||
|
||||
@ -3,8 +3,7 @@ package cli_test
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/nft"
|
||||
@ -35,7 +34,7 @@ func (s *CLITestSuite) TestQueryClass() {
|
||||
cmd := cli.GetCmdQueryClass()
|
||||
var args []string
|
||||
args = append(args, tc.args.ClassID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
|
||||
if tc.expectErr {
|
||||
@ -65,7 +64,7 @@ func (s *CLITestSuite) TestQueryClasses() {
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.GetCmdQueryClasses()
|
||||
var args []string
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
if tc.expectErr {
|
||||
s.Require().Error(err)
|
||||
@ -107,7 +106,7 @@ func (s *CLITestSuite) TestQueryNFT() {
|
||||
var args []string
|
||||
args = append(args, tc.args.ClassID)
|
||||
args = append(args, tc.args.ID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
if tc.expectErr {
|
||||
@ -160,7 +159,7 @@ func (s *CLITestSuite) TestQueryNFTs() {
|
||||
var args []string
|
||||
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagClassID, tc.args.ClassID))
|
||||
args = append(args, fmt.Sprintf("--%s=%s", cli.FlagOwner, tc.args.Owner))
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
if tc.expectErr {
|
||||
@ -203,7 +202,7 @@ func (s *CLITestSuite) TestQueryOwner() {
|
||||
var args []string
|
||||
args = append(args, tc.args.ClassID)
|
||||
args = append(args, tc.args.ID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
if tc.expectErr {
|
||||
@ -248,7 +247,7 @@ func (s *CLITestSuite) TestQueryBalance() {
|
||||
var args []string
|
||||
args = append(args, tc.args.Owner)
|
||||
args = append(args, tc.args.ClassID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
if tc.expectErr {
|
||||
@ -287,7 +286,7 @@ func (s *CLITestSuite) TestQuerySupply() {
|
||||
cmd := cli.GetCmdQuerySupply()
|
||||
var args []string
|
||||
args = append(args, tc.args.ClassID)
|
||||
args = append(args, fmt.Sprintf("--%s=json", tmcli.OutputFlag))
|
||||
args = append(args, fmt.Sprintf("--%s=json", flags.FlagOutput))
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(s.clientCtx, cmd, args)
|
||||
if tc.expectErr {
|
||||
|
||||
@ -6,11 +6,11 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"cosmossdk.io/depinject"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
||||
pruningtypes "github.com/cosmos/cosmos-sdk/store/pruning/types"
|
||||
@ -115,7 +115,7 @@ func (s *IntegrationTestSuite) TestNewQuerySubspaceParamsCmd() {
|
||||
"json output",
|
||||
[]string{
|
||||
"foo", "bar",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
`{"subspace":"foo","key":"bar","value":"\"1234\""}`,
|
||||
},
|
||||
@ -123,7 +123,7 @@ func (s *IntegrationTestSuite) TestNewQuerySubspaceParamsCmd() {
|
||||
"text output",
|
||||
[]string{
|
||||
"foo", "bar",
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
},
|
||||
`key: bar
|
||||
subspace: foo
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -89,7 +88,7 @@ func (s *CLITestSuite) TestGetCmdQuerySigningInfo() {
|
||||
"valid address (json output)",
|
||||
[]string{
|
||||
pubKeyStr,
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -98,7 +97,7 @@ func (s *CLITestSuite) TestGetCmdQuerySigningInfo() {
|
||||
"valid address (text output)",
|
||||
[]string{
|
||||
pubKeyStr,
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -129,11 +128,11 @@ func (s *CLITestSuite) TestGetCmdQueryParams() {
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/cosmos/gogoproto/proto"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
@ -22,12 +21,12 @@ func (s *CLITestSuite) TestGetCmdQueryValidator() {
|
||||
}{
|
||||
{
|
||||
"with invalid address ",
|
||||
[]string{"somethinginvalidaddress", fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{"somethinginvalidaddress", fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"happy case",
|
||||
[]string{sdk.ValAddress(s.addrs[0]).String(), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{sdk.ValAddress(s.addrs[0]).String(), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
false,
|
||||
},
|
||||
}
|
||||
@ -57,14 +56,14 @@ func (s *CLITestSuite) TestGetCmdQueryValidators() {
|
||||
{
|
||||
"one validator case",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagLimit),
|
||||
},
|
||||
1,
|
||||
},
|
||||
{
|
||||
"multi validator case",
|
||||
[]string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
[]string{fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
0,
|
||||
},
|
||||
}
|
||||
@ -97,7 +96,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegation() {
|
||||
[]string{
|
||||
"wrongDelAddr",
|
||||
s.addrs[1].String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil,
|
||||
},
|
||||
@ -106,7 +105,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegation() {
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true, nil,
|
||||
},
|
||||
@ -115,7 +114,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegation() {
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
sdk.ValAddress(s.addrs[1]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
&types.DelegationResponse{},
|
||||
@ -159,7 +158,7 @@ func (s *CLITestSuite) TestGetCmdQueryDelegations() {
|
||||
"valid request (height specific)",
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -205,7 +204,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorDelegations() {
|
||||
"valid request(height specific)",
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
false,
|
||||
@ -240,7 +239,7 @@ func (s *CLITestSuite) TestGetCmdQueryUnbondingDelegations() {
|
||||
"wrong delegator address",
|
||||
[]string{
|
||||
"wrongDelAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -248,7 +247,7 @@ func (s *CLITestSuite) TestGetCmdQueryUnbondingDelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -285,7 +284,7 @@ func (s *CLITestSuite) TestGetCmdQueryUnbondingDelegation() {
|
||||
[]string{
|
||||
"wrongDelAddr",
|
||||
s.addrs[0].String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -294,7 +293,7 @@ func (s *CLITestSuite) TestGetCmdQueryUnbondingDelegation() {
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -303,7 +302,7 @@ func (s *CLITestSuite) TestGetCmdQueryUnbondingDelegation() {
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
sdk.ValAddress(s.addrs[1]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -339,7 +338,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorUnbondingDelegations() {
|
||||
"wrong validator address",
|
||||
[]string{
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -347,7 +346,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorUnbondingDelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
sdk.ValAddress(s.addrs[0]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -382,7 +381,7 @@ func (s *CLITestSuite) TestGetCmdQueryRedelegations() {
|
||||
"wrong delegator address",
|
||||
[]string{
|
||||
"wrongdeladdr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -390,7 +389,7 @@ func (s *CLITestSuite) TestGetCmdQueryRedelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
s.addrs[0].String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -427,7 +426,7 @@ func (s *CLITestSuite) TestGetCmdQueryRedelegation() {
|
||||
"wrongdeladdr",
|
||||
sdk.ValAddress(s.addrs[0]).String(),
|
||||
sdk.ValAddress(s.addrs[1]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -437,7 +436,7 @@ func (s *CLITestSuite) TestGetCmdQueryRedelegation() {
|
||||
s.addrs[0].String(),
|
||||
"wrongSrcValAddress",
|
||||
sdk.ValAddress(s.addrs[1]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -447,7 +446,7 @@ func (s *CLITestSuite) TestGetCmdQueryRedelegation() {
|
||||
s.addrs[0].String(),
|
||||
sdk.ValAddress(s.addrs[0]).String(),
|
||||
"wrongDestValAddress",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -457,7 +456,7 @@ func (s *CLITestSuite) TestGetCmdQueryRedelegation() {
|
||||
s.addrs[0].String(),
|
||||
sdk.ValAddress(s.addrs[0]).String(),
|
||||
sdk.ValAddress(s.addrs[1]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -493,7 +492,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorRedelegations() {
|
||||
"wrong validator address",
|
||||
[]string{
|
||||
"wrongValAddr",
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
true,
|
||||
},
|
||||
@ -501,7 +500,7 @@ func (s *CLITestSuite) TestGetCmdQueryValidatorRedelegations() {
|
||||
"valid request",
|
||||
[]string{
|
||||
sdk.ValAddress(s.addrs[0]).String(),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
},
|
||||
false,
|
||||
},
|
||||
@ -535,7 +534,7 @@ func (s *CLITestSuite) TestGetCmdQueryPool() {
|
||||
{
|
||||
"with text",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=text", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=text", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
`bonded_tokens: "0"
|
||||
@ -544,7 +543,7 @@ not_bonded_tokens: "0"`,
|
||||
{
|
||||
"with json",
|
||||
[]string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=json", flags.FlagOutput),
|
||||
fmt.Sprintf("--%s=1", flags.FlagHeight),
|
||||
},
|
||||
`{"not_bonded_tokens":"0","bonded_tokens":"0"}`,
|
||||
|
||||
@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
rpcclientmock "github.com/tendermint/tendermint/rpc/client/mock"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
@ -43,12 +42,12 @@ func TestModuleVersionsCLI(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
msg: "test full query with json output",
|
||||
args: []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
args: []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", flags.FlagOutput)},
|
||||
expCmdOuptut: `--height=1 --output=json`,
|
||||
},
|
||||
{
|
||||
msg: "test full query with text output",
|
||||
args: []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
args: []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", flags.FlagOutput)},
|
||||
expCmdOuptut: `--height=1 --output=text`,
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user