* Make JSONMarshaler require proto.Message * Use &msg with MarshalJSON * Use *LegacyAmino in queriers instead of JSONMarshaler * Revert ABCIMessageLogs String() and coins tests * Use LegacyAmino in client/debug and fix subspace tests * Use LegacyAmino in all legacy queriers and adapt simulation * Make AminoCodec implement Marshaler and some godoc fixes * Test fixes * Remove unrelevant comment * Use TxConfig.TxJSONEncoder * Use encoding/json in genutil cli migrate/validate genesis cmds * Address simulation related comments * Use JSONMarshaler in cli tests * Use proto.Message as respType in cli tests * Use tmjson for tm GenesisDoc * Update types/module/simulation.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update types/module/module_test.go Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Add godoc comments * Remove unused InsertKeyJSON * Fix tests Co-authored-by: Aaron Craelius <aaronc@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package cli_test
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"path"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
"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 TestMigrateGenesis(t *testing.T) {
|
|
home, cleanup := testutil.NewTestCaseDir(t)
|
|
t.Cleanup(cleanup)
|
|
|
|
cdc := makeCodec()
|
|
|
|
genesisPath := path.Join(home, "genesis.json")
|
|
target := "v0.36"
|
|
|
|
cmd := cli.MigrateGenesisCmd()
|
|
_ = testutil.ApplyMockIODiscardOutErr(cmd)
|
|
|
|
clientCtx := client.Context{}.WithLegacyAmino(cdc)
|
|
ctx := context.Background()
|
|
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx)
|
|
|
|
// Reject if we dont' have the right parameters or genesis does not exists
|
|
cmd.SetArgs([]string{target, genesisPath})
|
|
require.Error(t, cmd.ExecuteContext(ctx))
|
|
|
|
// Noop migration with minimal genesis
|
|
emptyGenesis := []byte(`{"chain_id":"test","app_state":{}}`)
|
|
require.NoError(t, ioutil.WriteFile(genesisPath, emptyGenesis, 0644))
|
|
|
|
cmd.SetArgs([]string{target, genesisPath})
|
|
require.NoError(t, cmd.ExecuteContext(ctx))
|
|
}
|