github.com/cosmos/cosmos-sdk@v0.50.10/x/staking/migrations/v3/store_test.go (about)

     1  package v3_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	storetypes "cosmossdk.io/store/types"
     9  
    10  	"github.com/cosmos/cosmos-sdk/testutil"
    11  	moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
    12  	paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
    13  	v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3"
    14  	"github.com/cosmos/cosmos-sdk/x/staking/types"
    15  )
    16  
    17  func TestStoreMigration(t *testing.T) {
    18  	encCfg := moduletestutil.MakeTestEncodingConfig()
    19  	stakingKey := storetypes.NewKVStoreKey("staking")
    20  	tStakingKey := storetypes.NewTransientStoreKey("transient_test")
    21  	ctx := testutil.DefaultContext(stakingKey, tStakingKey)
    22  	paramstore := paramtypes.NewSubspace(encCfg.Codec, encCfg.Amino, stakingKey, tStakingKey, "staking")
    23  	store := ctx.KVStore(stakingKey)
    24  
    25  	// Check no params
    26  	require.False(t, paramstore.Has(ctx, types.KeyMinCommissionRate))
    27  
    28  	// Run migrations.
    29  	err := v3.MigrateStore(ctx, store, encCfg.Codec, paramstore)
    30  	require.NoError(t, err)
    31  
    32  	// Make sure the new params are set.
    33  	require.True(t, paramstore.Has(ctx, types.KeyMinCommissionRate))
    34  }