mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
c59a491788
* (feat) update x/cdp to run every X blocks based off params (#1814)
* add new cdp module param to protonet genesis
* update cdp / cdp related tests for new module param
* update telemetry docs and setup for collecting against local node
* update kvool commit for new cdp param
(cherry picked from commit 4d62f47773
)
* add tests for configurable x/cdp begin blocker interval param
add migration for default value of param
* make adjustments based off pr feedback
* fix proto back compat check
64 lines
2.3 KiB
Go
64 lines
2.3 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"
|
|
|
|
v2cdp "github.com/kava-labs/kava/x/cdp/migrations/v2"
|
|
"github.com/kava-labs/kava/x/cdp/types"
|
|
)
|
|
|
|
func TestStoreMigrationAddsKeyTableIncludingNewParam(t *testing.T) {
|
|
encCfg := simapp.MakeTestEncodingConfig()
|
|
cdpKey := sdk.NewKVStoreKey(types.ModuleName)
|
|
tcdpKey := sdk.NewTransientStoreKey("transient_test")
|
|
ctx := testutil.DefaultContext(cdpKey, tcdpKey)
|
|
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, cdpKey, tcdpKey, types.ModuleName)
|
|
|
|
// Check param doesn't exist before
|
|
require.False(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
|
|
|
|
// Run migrations.
|
|
err := v2cdp.MigrateStore(ctx, paramstore)
|
|
require.NoError(t, err)
|
|
|
|
// Make sure the new params are set.
|
|
require.True(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
|
|
// Assert the value is what we expect
|
|
result := types.DefaultBeginBlockerExecutionBlockInterval
|
|
paramstore.Get(ctx, types.KeyBeginBlockerExecutionBlockInterval, &result)
|
|
require.Equal(t, result, types.DefaultBeginBlockerExecutionBlockInterval)
|
|
}
|
|
|
|
func TestStoreMigrationSetsNewParamOnExistingKeyTable(t *testing.T) {
|
|
encCfg := simapp.MakeTestEncodingConfig()
|
|
cdpKey := sdk.NewKVStoreKey(types.ModuleName)
|
|
tcdpKey := sdk.NewTransientStoreKey("transient_test")
|
|
ctx := testutil.DefaultContext(cdpKey, tcdpKey)
|
|
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, cdpKey, tcdpKey, 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.KeyBeginBlockerExecutionBlockInterval))
|
|
|
|
// Run migrations.
|
|
err := v2cdp.MigrateStore(ctx, paramstore)
|
|
require.NoError(t, err)
|
|
|
|
// Make sure the new params are set.
|
|
require.True(t, paramstore.Has(ctx, types.KeyBeginBlockerExecutionBlockInterval))
|
|
|
|
// Assert the value is what we expect
|
|
result := types.DefaultBeginBlockerExecutionBlockInterval
|
|
paramstore.Get(ctx, types.KeyBeginBlockerExecutionBlockInterval, &result)
|
|
require.Equal(t, result, types.DefaultBeginBlockerExecutionBlockInterval)
|
|
}
|