2022-06-13 09:41:53 +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"
|
|
|
|
|
2022-06-19 09:43:41 +00:00
|
|
|
"github.com/evmos/ethermint/encoding"
|
2022-06-13 09:41:53 +00:00
|
|
|
|
2022-06-19 09:43:41 +00:00
|
|
|
"github.com/evmos/ethermint/app"
|
|
|
|
v2 "github.com/evmos/ethermint/x/evm/migrations/v2"
|
|
|
|
v2types "github.com/evmos/ethermint/x/evm/migrations/v2/types"
|
|
|
|
"github.com/evmos/ethermint/x/evm/types"
|
2022-06-13 09:41:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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(
|
2022-07-28 13:43:49 +00:00
|
|
|
encCfg.Codec, encCfg.Amino, feemarketKey, tFeeMarketKey, "evm",
|
2022-06-13 09:41:53 +00:00
|
|
|
).WithKeyTable(v2types.ParamKeyTable())
|
|
|
|
|
|
|
|
params := v2types.DefaultParams()
|
|
|
|
paramstore.SetParamSet(ctx, ¶ms)
|
|
|
|
|
|
|
|
require.Panics(t, func() {
|
|
|
|
var result bool
|
2022-06-22 10:51:14 +00:00
|
|
|
paramstore.Get(ctx, types.ParamStoreKeyAllowUnprotectedTxs, &result)
|
2022-06-13 09:41:53 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
paramstore = paramtypes.NewSubspace(
|
2022-07-28 13:43:49 +00:00
|
|
|
encCfg.Codec, encCfg.Amino, feemarketKey, tFeeMarketKey, "evm",
|
2022-06-13 09:41:53 +00:00
|
|
|
).WithKeyTable(types.ParamKeyTable())
|
|
|
|
err := v2.MigrateStore(ctx, ¶mstore)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var result bool
|
2022-06-22 10:51:14 +00:00
|
|
|
paramstore.Get(ctx, types.ParamStoreKeyAllowUnprotectedTxs, &result)
|
|
|
|
require.Equal(t, types.DefaultAllowUnprotectedTxs, result)
|
2022-06-13 09:41:53 +00:00
|
|
|
}
|