mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +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
55 lines
1.8 KiB
Go
55 lines
1.8 KiB
Go
package v2_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/cosmos/cosmos-sdk/simapp"
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
|
|
v2evmutil "github.com/kava-labs/kava/x/evmutil/migrations/v2"
|
|
"github.com/kava-labs/kava/x/evmutil/types"
|
|
)
|
|
|
|
func TestStoreMigrationAddsKeyTableIncludingNewParam(t *testing.T) {
|
|
encCfg := simapp.MakeTestEncodingConfig()
|
|
evmutilKey := sdk.NewKVStoreKey(types.ModuleName)
|
|
tEvmutilKey := sdk.NewTransientStoreKey("transient_test")
|
|
ctx := testutil.DefaultContext(evmutilKey, tEvmutilKey)
|
|
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, evmutilKey, tEvmutilKey, types.ModuleName)
|
|
|
|
// Check param doesn't exist before
|
|
require.False(t, paramstore.Has(ctx, types.KeyAllowedNativeDenoms))
|
|
|
|
// Run migrations.
|
|
err := v2evmutil.MigrateStore(ctx, paramstore)
|
|
require.NoError(t, err)
|
|
|
|
// Make sure the new params are set.
|
|
require.True(t, paramstore.Has(ctx, types.KeyAllowedNativeDenoms))
|
|
}
|
|
|
|
func TestStoreMigrationSetsNewParamOnExistingKeyTable(t *testing.T) {
|
|
encCfg := simapp.MakeTestEncodingConfig()
|
|
evmutilKey := sdk.NewKVStoreKey(types.ModuleName)
|
|
tEvmutilKey := sdk.NewTransientStoreKey("transient_test")
|
|
ctx := testutil.DefaultContext(evmutilKey, tEvmutilKey)
|
|
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, evmutilKey, tEvmutilKey, types.ModuleName)
|
|
paramstore.WithKeyTable(types.ParamKeyTable())
|
|
|
|
// expect it to have key table
|
|
require.True(t, paramstore.HasKeyTable())
|
|
// expect it to not have new param
|
|
require.False(t, paramstore.Has(ctx, types.KeyAllowedNativeDenoms))
|
|
|
|
// Run migrations.
|
|
err := v2evmutil.MigrateStore(ctx, paramstore)
|
|
require.NoError(t, err)
|
|
|
|
// Make sure the new params are set.
|
|
require.True(t, paramstore.Has(ctx, types.KeyAllowedNativeDenoms))
|
|
}
|