refactor(x/params): use mocks for testing (#12473)
* remove dependency on simapp from x/params keeper tests * refactor x/params proposal_handler_test away from simapp * update mockgen * import ordering * more import ordering
This commit is contained in:
@@ -3,16 +3,17 @@ package params_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
|
||||
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/testutil"
|
||||
paramstestutil "github.com/cosmos/cosmos-sdk/x/params/testutil"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
@@ -31,16 +32,20 @@ type HandlerTestSuite struct {
|
||||
}
|
||||
|
||||
func (suite *HandlerTestSuite) SetupTest() {
|
||||
var paramsKeeper keeper.Keeper
|
||||
app, err := simtestutil.Setup(
|
||||
testutil.AppConfig,
|
||||
¶msKeeper,
|
||||
&suite.stakingKeeper,
|
||||
)
|
||||
suite.Require().NoError(err)
|
||||
encodingCfg := moduletestutil.MakeTestEncodingConfig(params.AppModuleBasic{})
|
||||
key := sdk.NewKVStoreKey(paramtypes.StoreKey)
|
||||
tkey := sdk.NewTransientStoreKey("params_transient_test")
|
||||
|
||||
ctx := testutil.DefaultContext(key, tkey)
|
||||
paramsKeeper := keeper.NewKeeper(encodingCfg.Codec, encodingCfg.Amino, key, tkey)
|
||||
paramsKeeper.Subspace("staking").WithKeyTable(stakingtypes.ParamKeyTable())
|
||||
ctrl := gomock.NewController(suite.T())
|
||||
stakingKeeper := paramstestutil.NewMockStakingKeeper(ctrl)
|
||||
stakingKeeper.EXPECT().MaxValidators(ctx).Return(uint32(1))
|
||||
|
||||
suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{})
|
||||
suite.govHandler = params.NewParamChangeProposalHandler(paramsKeeper)
|
||||
suite.stakingKeeper = stakingKeeper
|
||||
suite.ctx = ctx
|
||||
}
|
||||
|
||||
func TestHandlerTestSuite(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user