cosmos-sdk/x/staking/migrations/v3/store_test.go
Likhita Polavarapu 7559d9ecd3
refactor: create go.mod for store (#14746)
Co-authored-by: Marko <marbar3778@yahoo.com>
2023-01-25 13:31:56 +00:00

34 lines
1.0 KiB
Go

package v3_test
import (
"testing"
"github.com/stretchr/testify/require"
storetypes "cosmossdk.io/store/types"
"github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)
func TestStoreMigration(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig()
stakingKey := storetypes.NewKVStoreKey("staking")
tStakingKey := storetypes.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(stakingKey, tStakingKey)
paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, stakingKey, tStakingKey, "staking")
// Check no params
require.False(t, paramstore.Has(ctx, types.KeyMinCommissionRate))
// Run migrations.
err := v3.MigrateStore(ctx, stakingKey, encCfg.Codec, paramstore)
require.NoError(t, err)
// Make sure the new params are set.
require.True(t, paramstore.Has(ctx, types.KeyMinCommissionRate))
}