laconicd-deprecated/x/evm/migrations/v2/migration_test.go
crypto-facs c4417713fa
imp(evm): define minimum GasUsed proportional to GasLimit (#1087)
* min gas denominator implementation

* update changelog

* modify MinGasDenominator type to sdk.Dec

* fix typo in comments

* add comments

* update comment

* refactor logic

* remove unnecesary test

* fix typo on proto

* rename param

* fix tests

* use truncate and run mod tidy

* comment to default value

* update changelog

* rename temporary gas used

* integration tests

* add migrations

* add default as var

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
2022-05-25 13:52:34 +00:00

47 lines
1.4 KiB
Go

package v2_test
import (
"fmt"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/stretchr/testify/require"
"github.com/tharsis/ethermint/app"
"github.com/tharsis/ethermint/encoding"
v2 "github.com/tharsis/ethermint/x/evm/migrations/v2"
"github.com/tharsis/ethermint/x/evm/types"
"testing"
)
func TestAddMinGasMultiplierParam(t *testing.T) {
encCfg := encoding.MakeConfig(app.ModuleBasics)
erc20Key := sdk.NewKVStoreKey(types.StoreKey)
tErc20Key := sdk.NewTransientStoreKey(fmt.Sprintf("%s_test", types.StoreKey))
ctx := testutil.DefaultContext(erc20Key, tErc20Key)
paramStore := paramtypes.NewSubspace(
encCfg.Marshaler, encCfg.Amino, erc20Key, tErc20Key, "erc20",
)
paramStore = paramStore.WithKeyTable(types.ParamKeyTable())
require.True(t, paramStore.HasKeyTable())
// check no param
require.False(t, paramStore.Has(ctx, types.ParamStoreKeyMinGasMultiplier))
// Run migrations
err := v2.AddMinGasMultiplierParam(ctx, &paramStore)
require.NoError(t, err)
// Make sure the params are set
require.True(t, paramStore.Has(ctx, types.ParamStoreKeyMinGasMultiplier))
var minGasMultiplier sdk.Dec
// Make sure the new params are set
require.NotPanics(t, func() {
paramStore.Get(ctx, types.ParamStoreKeyMinGasMultiplier, &minGasMultiplier)
})
// check the params is up
require.Equal(t, minGasMultiplier, types.DefaultMinGasMultiplier)
}