package v4_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/evmos/ethermint/app"
"github.com/evmos/ethermint/encoding"
v4 "github.com/evmos/ethermint/x/evm/migrations/v4"
"github.com/evmos/ethermint/x/evm/types"
)
type mockSubspace struct {
ps types.Params
}
func newMockSubspace(ps types.Params) mockSubspace {
return mockSubspace{ps: ps}
func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps types.LegacyParams) {
*ps.(*types.Params) = ms.ps
func TestMigrate(t *testing.T) {
encCfg := encoding.MakeConfig(app.ModuleBasics)
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(types.ModuleName)
tKey := sdk.NewTransientStoreKey(types.TransientKey)
ctx := testutil.DefaultContext(storeKey, tKey)
kvStore := ctx.KVStore(storeKey)
legacySubspace := newMockSubspace(types.DefaultParams())
require.NoError(t, v4.MigrateStore(ctx, storeKey, legacySubspace, cdc))
paramsBz := kvStore.Get(types.KeyPrefixParams)
var params types.Params
cdc.MustUnmarshal(paramsBz, ¶ms)
require.Equal(t, params, legacySubspace.ps)