2022-03-30 17:16:37 +00:00
|
|
|
package v010_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"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/tharsis/ethermint/encoding"
|
|
|
|
|
|
|
|
"github.com/tharsis/ethermint/app"
|
|
|
|
feemarketkeeper "github.com/tharsis/ethermint/x/feemarket/keeper"
|
|
|
|
v010 "github.com/tharsis/ethermint/x/feemarket/migrations/v010"
|
|
|
|
"github.com/tharsis/ethermint/x/feemarket/types"
|
|
|
|
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMigrateStore(t *testing.T) {
|
|
|
|
encCfg := encoding.MakeConfig(app.ModuleBasics)
|
|
|
|
feemarketKey := sdk.NewKVStoreKey(feemarkettypes.StoreKey)
|
2022-04-26 10:39:18 +00:00
|
|
|
tFeeMarketKey := sdk.NewTransientStoreKey("margetkey_test")
|
2022-03-30 17:16:37 +00:00
|
|
|
ctx := testutil.DefaultContext(feemarketKey, tFeeMarketKey)
|
|
|
|
paramstore := paramtypes.NewSubspace(
|
2022-04-26 10:39:18 +00:00
|
|
|
encCfg.Codec, encCfg.Amino, feemarketKey, tFeeMarketKey, "feemarket",
|
2022-03-30 17:16:37 +00:00
|
|
|
)
|
2022-04-26 10:39:18 +00:00
|
|
|
fmKeeper := feemarketkeeper.NewKeeper(encCfg.Codec, feemarketKey, paramstore)
|
2022-03-30 17:16:37 +00:00
|
|
|
fmKeeper.SetParams(ctx, types.DefaultParams())
|
|
|
|
require.True(t, paramstore.HasKeyTable())
|
|
|
|
|
|
|
|
// check that the fee market is not nil
|
|
|
|
err := v010.MigrateStore(ctx, ¶mstore, feemarketKey)
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.False(t, ctx.KVStore(feemarketKey).Has(v010.KeyPrefixBaseFeeV1))
|
|
|
|
|
|
|
|
params := fmKeeper.GetParams(ctx)
|
|
|
|
require.False(t, params.BaseFee.IsNil())
|
|
|
|
|
|
|
|
baseFee := fmKeeper.GetBaseFee(ctx)
|
|
|
|
require.NotNil(t, baseFee)
|
|
|
|
|
|
|
|
require.Equal(t, baseFee.Int64(), params.BaseFee.Int64())
|
|
|
|
}
|