refactor: clean-up test helpers and tmcli (#13805)

This commit is contained in:
Julien Robert
2022-11-09 11:13:27 +00:00
committed by GitHub
parent 76be73022a
commit 4f7d9ea233
36 changed files with 453 additions and 582 deletions
+13 -14
View File
@@ -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,
},
}