cosmos-sdk/x/staking/migrations/v3/store_test.go
Julien Robert f770f8cac6
refactor!: make simapp.MakeTestEncodingConfig private (#12747)
* feat: make `simapp.MakeTestEncodingConfig` private

* fix legacy build

* update changelog and upgrading.md

* updates docs
2022-07-27 17:23:56 +02:00

33 lines
1.0 KiB
Go

package v3_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
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 := sdk.NewKVStoreKey("staking")
tStakingKey := sdk.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))
}