diff --git a/x/evm/migrations/v4/migrate_test.go b/x/evm/migrations/v4/migrate_test.go index bdaf50a8aa..5c56925123 100644 --- a/x/evm/migrations/v4/migrate_test.go +++ b/x/evm/migrations/v4/migrate_test.go @@ -8,6 +8,7 @@ import ( "github.com/evmos/ethermint/x/evm/types" storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/evmos/ethermint/encoding" @@ -34,26 +35,34 @@ func TestMigrate(t *testing.T) { storeKey := storetypes.NewKVStoreKey(types.ModuleName) tKey := storetypes.NewTransientStoreKey(types.TransientKey) ctx := testutil.DefaultContext(storeKey, tKey) - kvStore := ctx.KVStore(storeKey) + storeService := runtime.NewKVStoreService(storeKey) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v4.MigrateStore(ctx, kvStore, legacySubspace, cdc)) + require.NoError(t, v4.MigrateStore(ctx, storeService, legacySubspace, cdc)) + + kvStore := storeService.OpenKVStore(ctx) // Get all the new parameters from the kvStore var evmDenom string - bz := kvStore.Get(types.ParamStoreKeyEVMDenom) + bz, err := kvStore.Get(types.ParamStoreKeyEVMDenom) + require.NoError(t, err) evmDenom = string(bz) - allowUnprotectedTx := kvStore.Has(types.ParamStoreKeyAllowUnprotectedTxs) - enableCreate := kvStore.Has(types.ParamStoreKeyEnableCreate) - enableCall := kvStore.Has(types.ParamStoreKeyEnableCall) + allowUnprotectedTx, err := kvStore.Has(types.ParamStoreKeyAllowUnprotectedTxs) + require.NoError(t, err) + enableCreate, err := kvStore.Has(types.ParamStoreKeyEnableCreate) + require.NoError(t, err) + enableCall, err := kvStore.Has(types.ParamStoreKeyEnableCall) + require.NoError(t, err) var chainCfg v4types.V4ChainConfig - bz = kvStore.Get(types.ParamStoreKeyChainConfig) + bz, err = kvStore.Get(types.ParamStoreKeyChainConfig) + require.NoError(t, err) cdc.MustUnmarshal(bz, &chainCfg) var extraEIPs v4types.ExtraEIPs - bz = kvStore.Get(types.ParamStoreKeyExtraEIPs) + bz, err = kvStore.Get(types.ParamStoreKeyExtraEIPs) + require.NoError(t, err) cdc.MustUnmarshal(bz, &extraEIPs) require.Equal(t, []int64(nil), extraEIPs.EIPs) diff --git a/x/evm/migrations/v5/migrate_test.go b/x/evm/migrations/v5/migrate_test.go index d051d6873b..8fc25826b0 100644 --- a/x/evm/migrations/v5/migrate_test.go +++ b/x/evm/migrations/v5/migrate_test.go @@ -4,6 +4,7 @@ import ( "testing" storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" "github.com/stretchr/testify/require" @@ -20,13 +21,15 @@ func TestMigrate(t *testing.T) { storeKey := storetypes.NewKVStoreKey(types.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) - kvStore := ctx.KVStore(storeKey) + storeService := runtime.NewKVStoreService(storeKey) extraEIPs := v5types.V5ExtraEIPs{EIPs: types.AvailableExtraEIPs} extraEIPsBz := cdc.MustMarshal(&extraEIPs) chainConfig := types.DefaultChainConfig() chainConfigBz := cdc.MustMarshal(&chainConfig) + kvStore := storeService.OpenKVStore(ctx) + // Set the params in the store kvStore.Set(types.ParamStoreKeyEVMDenom, []byte("aphoton")) kvStore.Set(types.ParamStoreKeyEnableCreate, []byte{0x01}) @@ -35,10 +38,11 @@ func TestMigrate(t *testing.T) { kvStore.Set(types.ParamStoreKeyExtraEIPs, extraEIPsBz) kvStore.Set(types.ParamStoreKeyChainConfig, chainConfigBz) - err := v5.MigrateStore(ctx, kvStore, cdc) + err := v5.MigrateStore(ctx, storeService, cdc) require.NoError(t, err) - paramsBz := kvStore.Get(types.KeyPrefixParams) + paramsBz, err := kvStore.Get(types.KeyPrefixParams) + require.NoError(t, err) var params types.Params cdc.MustUnmarshal(paramsBz, ¶ms) @@ -51,10 +55,16 @@ func TestMigrate(t *testing.T) { require.Equal(t, extraEIPs.EIPs, params.ExtraEIPs) // check that the keys are deleted - require.False(t, kvStore.Has(types.ParamStoreKeyEVMDenom)) - require.False(t, kvStore.Has(types.ParamStoreKeyEnableCreate)) - require.False(t, kvStore.Has(types.ParamStoreKeyEnableCall)) - require.False(t, kvStore.Has(types.ParamStoreKeyAllowUnprotectedTxs)) - require.False(t, kvStore.Has(types.ParamStoreKeyExtraEIPs)) - require.False(t, kvStore.Has(types.ParamStoreKeyChainConfig)) + value, _ := kvStore.Has(types.ParamStoreKeyEVMDenom) + require.False(t, value) + value, _ = kvStore.Has(types.ParamStoreKeyEnableCreate) + require.False(t, value) + value, _ = kvStore.Has(types.ParamStoreKeyEnableCall) + require.False(t, value) + value, _ = kvStore.Has(types.ParamStoreKeyAllowUnprotectedTxs) + require.False(t, value) + value, _ = kvStore.Has(types.ParamStoreKeyExtraEIPs) + require.False(t, value) + value, _ = kvStore.Has(types.ParamStoreKeyChainConfig) + require.False(t, value) } diff --git a/x/feemarket/migrations/v4/migrate.go b/x/feemarket/migrations/v4/migrate.go index dc93d9824d..546749dacd 100644 --- a/x/feemarket/migrations/v4/migrate.go +++ b/x/feemarket/migrations/v4/migrate.go @@ -16,7 +16,10 @@ func MigrateStore( legacySubspace types.Subspace, cdc codec.BinaryCodec, ) error { - var params types.Params + var ( + store = storeService.OpenKVStore(ctx) + params types.Params + ) legacySubspace.GetParamSetIfExists(ctx, ¶ms) @@ -29,7 +32,6 @@ func MigrateStore( return err } - store := storeService.OpenKVStore(ctx) store.Set(types.ParamsKey, bz) return nil diff --git a/x/feemarket/migrations/v4/migrate_test.go b/x/feemarket/migrations/v4/migrate_test.go index 6f32562283..372d743343 100644 --- a/x/feemarket/migrations/v4/migrate_test.go +++ b/x/feemarket/migrations/v4/migrate_test.go @@ -4,6 +4,7 @@ import ( "testing" storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/evmos/ethermint/encoding" @@ -35,15 +36,17 @@ func TestMigrate(t *testing.T) { storeKey := storetypes.NewKVStoreKey(types.ModuleName) tKey := storetypes.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(storeKey, tKey) - kvStore := ctx.KVStore(storeKey) + storeService := runtime.NewKVStoreService(storeKey) legacySubspaceEmpty := newMockSubspaceEmpty() - require.Error(t, v4.MigrateStore(ctx, kvStore, legacySubspaceEmpty, cdc)) + require.Error(t, v4.MigrateStore(ctx, storeService, legacySubspaceEmpty, cdc)) legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v4.MigrateStore(ctx, kvStore, legacySubspace, cdc)) + require.NoError(t, v4.MigrateStore(ctx, storeService, legacySubspace, cdc)) - paramsBz := kvStore.Get(types.ParamsKey) + kvStore := storeService.OpenKVStore(ctx) + paramsBz, err := kvStore.Get(types.ParamsKey) + require.NoError(t, err) var params types.Params cdc.MustUnmarshal(paramsBz, ¶ms)