mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 00:35:18 +00:00
ff709d73e1
* add proto for allowed sdk denoms -> evm conversion * add validation for AllowedNativeCoinERC20Token * add validation for AllowedNativeCoinERC20Tokens * add AllowedNativeDenoms into params & genesis * add evmutil Params.Validate() test * fix eip712 ante test * update changelog * update internal testnet genesis.json * update state & param specs updates to the sections describing functionality will be updated once that functionality actually exists... :) * update field decimal -> decimals field now matches erc20 spec * add validation decimals will cast to uint8 * add v2 store migration for evmutil * create & register evmutil migrations * adds migrator to evmutil's keeper * sets up Migrate1To2 migration * registers migration in module * updates GetParams to properly handle historic block queries * add unit test for GetParams with historic store
63 lines
1.8 KiB
Go
63 lines
1.8 KiB
Go
package keeper_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/x/evmutil/keeper"
|
|
"github.com/kava-labs/kava/x/evmutil/testutil"
|
|
"github.com/kava-labs/kava/x/evmutil/types"
|
|
)
|
|
|
|
type ParamsTestSuite struct {
|
|
testutil.Suite
|
|
}
|
|
|
|
func TestParamsSuite(t *testing.T) {
|
|
suite.Run(t, new(ParamsTestSuite))
|
|
}
|
|
|
|
func (suite *ParamsTestSuite) TestEnabledConversionPair() {
|
|
pairAddr := testutil.MustNewInternalEVMAddressFromString("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
|
|
expPair := types.ConversionPair{
|
|
KavaERC20Address: pairAddr.Bytes(),
|
|
Denom: "weth",
|
|
}
|
|
params := types.DefaultParams()
|
|
params.EnabledConversionPairs = []types.ConversionPair{expPair}
|
|
suite.Keeper.SetParams(suite.Ctx, params)
|
|
|
|
actualPair, err := suite.Keeper.GetEnabledConversionPairFromERC20Address(
|
|
suite.Ctx,
|
|
pairAddr,
|
|
)
|
|
suite.Require().NoError(err)
|
|
suite.Require().Equal(expPair, actualPair)
|
|
}
|
|
|
|
func (suite *ParamsTestSuite) TestHistoricParamsQuery() {
|
|
// setup a params store that lacks allowed_native_denoms param (as was the case in v1)
|
|
oldParamStore := suite.App.GetParamsKeeper().Subspace("test_subspace_for_evmutil")
|
|
oldParamStore.WithKeyTable(types.ParamKeyTable())
|
|
oldParamStore.Set(suite.Ctx, types.KeyEnabledConversionPairs, types.ConversionPairs{})
|
|
|
|
suite.True(oldParamStore.Has(suite.Ctx, types.KeyEnabledConversionPairs))
|
|
suite.False(oldParamStore.Has(suite.Ctx, types.KeyAllowedNativeDenoms))
|
|
|
|
oldStateKeeper := keeper.NewKeeper(
|
|
suite.App.AppCodec(),
|
|
sdk.NewKVStoreKey(types.StoreKey),
|
|
oldParamStore,
|
|
suite.App.GetBankKeeper(),
|
|
suite.App.GetAccountKeeper(),
|
|
)
|
|
|
|
// prior to making GetParams() use GetParamSetIfExists, this would panic.
|
|
suite.NotPanics(func() {
|
|
_ = oldStateKeeper.GetParams(suite.Ctx)
|
|
})
|
|
}
|