laconicd-deprecated/x/evm/migrations/v2/migrate_test.go

48 lines
1.4 KiB
Go
Raw Permalink Normal View History

2022-10-10 10:38:33 +00:00
package v2_test
import (
"fmt"
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cerc-io/laconicd/encoding"
"github.com/cerc-io/laconicd/app"
v2 "github.com/cerc-io/laconicd/x/evm/migrations/v2"
v2types "github.com/cerc-io/laconicd/x/evm/migrations/v2/types"
"github.com/cerc-io/laconicd/x/evm/types"
)
func TestMigrateStore(t *testing.T) {
encCfg := encoding.MakeConfig(app.ModuleBasics)
feemarketKey := sdk.NewKVStoreKey(types.StoreKey)
tFeeMarketKey := sdk.NewTransientStoreKey(fmt.Sprintf("%s_test", types.StoreKey))
ctx := testutil.DefaultContext(feemarketKey, tFeeMarketKey)
paramstore := paramtypes.NewSubspace(
encCfg.Codec, encCfg.Amino, feemarketKey, tFeeMarketKey, "evm",
).WithKeyTable(v2types.ParamKeyTable())
params := v2types.DefaultParams()
paramstore.SetParamSet(ctx, &params)
require.Panics(t, func() {
var result bool
paramstore.Get(ctx, types.ParamStoreKeyAllowUnprotectedTxs, &result)
})
paramstore = paramtypes.NewSubspace(
encCfg.Codec, encCfg.Amino, feemarketKey, tFeeMarketKey, "evm",
).WithKeyTable(types.ParamKeyTable())
err := v2.MigrateStore(ctx, &paramstore)
require.NoError(t, err)
var result bool
paramstore.Get(ctx, types.ParamStoreKeyAllowUnprotectedTxs, &result)
require.Equal(t, types.DefaultAllowUnprotectedTxs, result)
}