github.com/cosmos/cosmos-sdk@v0.50.10/x/params/keeper/common_test.go (about)

     1  package keeper_test
     2  
     3  import (
     4  	storetypes "cosmossdk.io/store/types"
     5  
     6  	"github.com/cosmos/cosmos-sdk/codec"
     7  	sdktestutil "github.com/cosmos/cosmos-sdk/testutil"
     8  	sdk "github.com/cosmos/cosmos-sdk/types"
     9  	moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
    10  	"github.com/cosmos/cosmos-sdk/x/params"
    11  	paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
    12  )
    13  
    14  func testComponents() (*codec.LegacyAmino, sdk.Context, storetypes.StoreKey, storetypes.StoreKey, paramskeeper.Keeper) {
    15  	encodingConfig := moduletestutil.MakeTestEncodingConfig(params.AppModuleBasic{})
    16  	cdc := encodingConfig.Codec
    17  
    18  	legacyAmino := createTestCodec()
    19  	mkey := storetypes.NewKVStoreKey("test")
    20  	tkey := storetypes.NewTransientStoreKey("transient_test")
    21  	ctx := sdktestutil.DefaultContext(mkey, tkey)
    22  	keeper := paramskeeper.NewKeeper(cdc, legacyAmino, mkey, tkey)
    23  
    24  	return legacyAmino, ctx, mkey, tkey, keeper
    25  }
    26  
    27  type invalid struct{}
    28  
    29  type s struct {
    30  	I int
    31  }
    32  
    33  func createTestCodec() *codec.LegacyAmino {
    34  	cdc := codec.NewLegacyAmino()
    35  	sdk.RegisterLegacyAminoCodec(cdc)
    36  	cdc.RegisterConcrete(s{}, "test/s", nil)
    37  	cdc.RegisterConcrete(invalid{}, "test/invalid", nil)
    38  	return cdc
    39  }