forked from cerc-io/laconicd-deprecated
c4417713fa
* 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>
47 lines
1.4 KiB
Go
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, ¶mStore)
|
|
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)
|
|
}
|