Make integration test suites reusable by apps (#6711)
* WIP on refactoring new integration tests.
* godocs
* godocs
* Fix ineff assign
* Updates
* Updates
* fix test
* refactor crisis, distr testsuites
* fix import issue
* refactor x/auth
* refactor x/authz
* refactor x/evidence
* refactor x/feegrant
* refactor x/genutil
* refactor x/gov
* refactor x/mint
* refactor x/params
* refactor x/{auth_vesting, slashing, staking}
* fix lint
* fix tests & lint
* fix lint
* fix tests
* lint
* lint
* fix lint memory
* add missing `norace` build flag
* update feegrant cfg
* fix lint
Co-authored-by: atheesh <atheesh@vitwit.com>
Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
This commit is contained in:
co-authored by
atheesh
atheeshp
parent
5ea817a6fb
commit
3c65c3dacd
@@ -1,169 +0,0 @@
|
||||
// +build norace
|
||||
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"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"
|
||||
testnet "github.com/cosmos/cosmos-sdk/testutil/network"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/client/cli"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
cfg testnet.Config
|
||||
network *testnet.Network
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
s.T().Log("setting up integration test suite")
|
||||
|
||||
cfg := testnet.DefaultConfig()
|
||||
genesisState := cfg.GenesisState
|
||||
cfg.NumValidators = 1
|
||||
|
||||
var mintData minttypes.GenesisState
|
||||
s.Require().NoError(cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData))
|
||||
|
||||
inflation := sdk.MustNewDecFromStr("1.0")
|
||||
mintData.Minter.Inflation = inflation
|
||||
mintData.Params.InflationMin = inflation
|
||||
mintData.Params.InflationMax = inflation
|
||||
|
||||
mintDataBz, err := cfg.Codec.MarshalJSON(&mintData)
|
||||
s.Require().NoError(err)
|
||||
genesisState[minttypes.ModuleName] = mintDataBz
|
||||
cfg.GenesisState = genesisState
|
||||
|
||||
s.cfg = cfg
|
||||
s.network = testnet.New(s.T(), cfg)
|
||||
|
||||
_, err = s.network.WaitForHeight(1)
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TearDownSuite() {
|
||||
s.T().Log("tearing down integration test suite")
|
||||
s.network.Cleanup()
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdQueryParams() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expectedOutput string
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
`{"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)},
|
||||
`blocks_per_year: "6311520"
|
||||
goal_bonded: "0.670000000000000000"
|
||||
inflation_max: "1.000000000000000000"
|
||||
inflation_min: "1.000000000000000000"
|
||||
inflation_rate_change: "0.130000000000000000"
|
||||
mint_denom: stake`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.GetCmdQueryParams()
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdQueryInflation() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expectedOutput string
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
`1.000000000000000000`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
`1.000000000000000000`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.GetCmdQueryInflation()
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expectedOutput string
|
||||
}{
|
||||
{
|
||||
"json output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)},
|
||||
`500000000.000000000000000000`,
|
||||
},
|
||||
{
|
||||
"text output",
|
||||
[]string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)},
|
||||
`500000000.000000000000000000`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
s.Run(tc.name, func() {
|
||||
cmd := cli.GetCmdQueryAnnualProvisions()
|
||||
clientCtx := val.ClientCtx
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
s.Require().NoError(err)
|
||||
s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(IntegrationTestSuite))
|
||||
}
|
||||
Reference in New Issue
Block a user