cosmos-sdk/x/genutil/client/testutil/migrate.go
Aaron Craelius 3c65c3dacd
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>
2021-04-23 14:49:49 -04:00

68 lines
1.6 KiB
Go

package testutil
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
)
func TestGetMigrationCallback(t *testing.T) {
for _, version := range cli.GetMigrationVersions() {
require.NotNil(t, cli.GetMigrationCallback(version))
}
}
func (s *IntegrationTestSuite) TestMigrateGenesis() {
val0 := s.network.Validators[0]
testCases := []struct {
name string
genesis string
target string
expErr bool
expErrMsg string
check func(jsonOut string)
}{
{
"migrate 0.34 to 0.36",
`{"chain_id":"test","app_state":{}}`,
"v0.36",
false, "", func(_ string) {},
},
{
"migrate 0.37 to 0.42",
v037Exported,
"v0.42",
true, "Make sure that you have correctly migrated all Tendermint consensus params", func(_ string) {},
},
{
"migrate 0.42 to 0.43",
v040Valid,
"v0.43",
false, "",
func(jsonOut string) {
// Make sure the json output contains the ADR-037 gov weighted votes.
s.Require().Contains(jsonOut, "\"weight\":\"1.000000000000000000\"")
},
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
genesisFile := testutil.WriteToNewTempFile(s.T(), tc.genesis)
jsonOutput, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.MigrateGenesisCmd(), []string{tc.target, genesisFile.Name()})
if tc.expErr {
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
s.Require().NoError(err)
tc.check(jsonOutput.String())
}
})
}
}