From 812b03af2a54a609c226cfb38444ba9403c37119 Mon Sep 17 00:00:00 2001 From: Draco Li Date: Fri, 22 Apr 2022 11:58:55 -0400 Subject: [PATCH] x/authz v17 migration (#1217) --- migrate/{ => v0_16}/go.mod | 0 migrate/v0_17/kava.go | 5 +++++ migrate/v0_17/migrate_test.go | 19 +++++++++++++++---- migrate/v0_17/testdata/genesis-v17.json | 3 +++ 4 files changed, 23 insertions(+), 4 deletions(-) rename migrate/{ => v0_16}/go.mod (100%) diff --git a/migrate/go.mod b/migrate/v0_16/go.mod similarity index 100% rename from migrate/go.mod rename to migrate/v0_16/go.mod diff --git a/migrate/v0_17/kava.go b/migrate/v0_17/kava.go index fd89675d..00b8b405 100644 --- a/migrate/v0_17/kava.go +++ b/migrate/v0_17/kava.go @@ -3,6 +3,7 @@ package v0_17 import ( "github.com/cosmos/cosmos-sdk/client" + authz "github.com/cosmos/cosmos-sdk/x/authz" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" evmtypes "github.com/tharsis/ethermint/x/evm/types" feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types" @@ -33,4 +34,8 @@ func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) { // x/feemarket feemarketState := feemarkettypes.DefaultGenesisState() appState[feemarkettypes.ModuleName] = codec.MustMarshalJSON(feemarketState) + + // x/authz + authzState := authz.DefaultGenesisState() + appState[authz.ModuleName] = codec.MustMarshalJSON(authzState) } diff --git a/migrate/v0_17/migrate_test.go b/migrate/v0_17/migrate_test.go index 34ec2d6d..fdafdd65 100644 --- a/migrate/v0_17/migrate_test.go +++ b/migrate/v0_17/migrate_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/cosmos/cosmos-sdk/client" + authz "github.com/cosmos/cosmos-sdk/x/authz" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" tmjson "github.com/tendermint/tendermint/libs/json" tmtypes "github.com/tendermint/tendermint/types" @@ -33,7 +34,7 @@ func TestMigrateGenesisDoc(t *testing.T) { } func TestMigrateEvmUtil(t *testing.T) { - appMap, ctx := migrateToV16AndGetAppMap(t) + appMap, ctx := migrateToV17AndGetAppMap(t) var genstate evmutiltypes.GenesisState err := ctx.Codec.UnmarshalJSON(appMap[evmutiltypes.ModuleName], &genstate) assert.NoError(t, err) @@ -41,7 +42,7 @@ func TestMigrateEvmUtil(t *testing.T) { } func TestMigrateEvm(t *testing.T) { - appMap, ctx := migrateToV16AndGetAppMap(t) + appMap, ctx := migrateToV17AndGetAppMap(t) var genstate evmtypes.GenesisState err := ctx.Codec.UnmarshalJSON(appMap[evmtypes.ModuleName], &genstate) assert.NoError(t, err) @@ -56,14 +57,24 @@ func TestMigrateEvm(t *testing.T) { } func TestMigrateFeeMarket(t *testing.T) { - appMap, ctx := migrateToV16AndGetAppMap(t) + appMap, ctx := migrateToV17AndGetAppMap(t) var genstate feemarkettypes.GenesisState err := ctx.Codec.UnmarshalJSON(appMap[feemarkettypes.ModuleName], &genstate) assert.NoError(t, err) assert.Equal(t, genstate, *feemarkettypes.DefaultGenesisState()) } -func migrateToV16AndGetAppMap(t *testing.T) (genutiltypes.AppMap, client.Context) { +func TestMigrateAuthz(t *testing.T) { + appMap, ctx := migrateToV17AndGetAppMap(t) + var genstate authz.GenesisState + err := ctx.Codec.UnmarshalJSON(appMap[authz.ModuleName], &genstate) + assert.NoError(t, err) + assert.Equal(t, genstate, authz.GenesisState{ + Authorization: []authz.GrantAuthorization{}, + }) +} + +func migrateToV17AndGetAppMap(t *testing.T) (genutiltypes.AppMap, client.Context) { genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v16.json")) assert.NoError(t, err) diff --git a/migrate/v0_17/testdata/genesis-v17.json b/migrate/v0_17/testdata/genesis-v17.json index b2c981aa..7c3fdb4c 100644 --- a/migrate/v0_17/testdata/genesis-v17.json +++ b/migrate/v0_17/testdata/genesis-v17.json @@ -2219,6 +2219,9 @@ "base_fee": "1000000000" }, "block_gas": "0" + }, + "authz": { + "authorization": [] } } }