forked from cerc-io/laconicd-deprecated
4f48176298
* refactor(params): store all params under one key in evm module (#1617) * refactor(params): store all params under one key in evm module * refactor(params): add changelog entry * refactor(params): update based on review comments. Remove params getter functions * refactor(params): refactor params store key * refactor(params): remove unnecessary store keys * refactor(params): add paramSetPairs for backwards compatibility * Update CHANGELOG.md * refactor(params): add license to params_legacy file * Apply suggestions from code review * fix(evm): handle RC1 params during migration (#1624) * fix(evm): handle RC1 params during migration * migration * fix: test case updated for RC1 * v5 migration * tests * tests pt2 * comment * execute make proto-all Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com> Co-authored-by: MalteHerrmann <malte@evmos.org> * Apply suggestions from code review * rm dup vars Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Vladislav Varadinov <vladislav.varadinov@gmail.com> Co-authored-by: MalteHerrmann <malte@evmos.org> (cherry picked from commit f07b14f1c409a6b738a0fadb50c9ba47d56cb821) # Conflicts: # CHANGELOG.md * update changelog Co-authored-by: Tomas Guerra <54514587+GAtom22@users.noreply.github.com> Co-authored-by: MalteHerrmann <42640438+MalteHerrmann@users.noreply.github.com> Co-authored-by: MalteHerrmann <malte@evmos.org>
62 lines
2.2 KiB
Go
62 lines
2.2 KiB
Go
package v5_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/evmos/ethermint/app"
|
|
"github.com/evmos/ethermint/encoding"
|
|
v5 "github.com/evmos/ethermint/x/evm/migrations/v5"
|
|
v5types "github.com/evmos/ethermint/x/evm/migrations/v5/types"
|
|
"github.com/evmos/ethermint/x/evm/types"
|
|
)
|
|
|
|
func TestMigrate(t *testing.T) {
|
|
encCfg := encoding.MakeConfig(app.ModuleBasics)
|
|
cdc := encCfg.Codec
|
|
|
|
storeKey := sdk.NewKVStoreKey(types.ModuleName)
|
|
tKey := sdk.NewTransientStoreKey("transient_test")
|
|
ctx := testutil.DefaultContext(storeKey, tKey)
|
|
kvStore := ctx.KVStore(storeKey)
|
|
|
|
extraEIPs := v5types.V5ExtraEIPs{EIPs: types.AvailableExtraEIPs}
|
|
extraEIPsBz := cdc.MustMarshal(&extraEIPs)
|
|
chainConfig := types.DefaultChainConfig()
|
|
chainConfigBz := cdc.MustMarshal(&chainConfig)
|
|
|
|
// Set the params in the store
|
|
kvStore.Set(types.ParamStoreKeyEVMDenom, []byte("aphoton"))
|
|
kvStore.Set(types.ParamStoreKeyEnableCreate, []byte{0x01})
|
|
kvStore.Set(types.ParamStoreKeyEnableCall, []byte{0x01})
|
|
kvStore.Set(types.ParamStoreKeyAllowUnprotectedTxs, []byte{0x01})
|
|
kvStore.Set(types.ParamStoreKeyExtraEIPs, extraEIPsBz)
|
|
kvStore.Set(types.ParamStoreKeyChainConfig, chainConfigBz)
|
|
|
|
err := v5.MigrateStore(ctx, storeKey, cdc)
|
|
require.NoError(t, err)
|
|
|
|
paramsBz := kvStore.Get(types.KeyPrefixParams)
|
|
var params types.Params
|
|
cdc.MustUnmarshal(paramsBz, ¶ms)
|
|
|
|
// test that the params have been migrated correctly
|
|
require.Equal(t, "aphoton", params.EvmDenom)
|
|
require.True(t, params.EnableCreate)
|
|
require.True(t, params.EnableCall)
|
|
require.True(t, params.AllowUnprotectedTxs)
|
|
require.Equal(t, chainConfig, params.ChainConfig)
|
|
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))
|
|
}
|