diff --git a/testutil/sims/weights.go b/testutil/sims/weights.go deleted file mode 100644 index c85345ffb74e..000000000000 --- a/testutil/sims/weights.go +++ /dev/null @@ -1,29 +0,0 @@ -package sims - -// Default simulation operation weights for messages and gov proposals -const ( - DefaultWeightMsgSend int = 100 - DefaultWeightMsgMultiSend int = 10 - DefaultWeightMsgSetWithdrawAddress int = 50 - DefaultWeightMsgWithdrawDelegationReward int = 50 - DefaultWeightMsgWithdrawValidatorCommission int = 50 - DefaultWeightMsgFundCommunityPool int = 50 - DefaultWeightMsgDeposit int = 100 - DefaultWeightMsgVote int = 67 - DefaultWeightMsgVoteWeighted int = 33 - DefaultWeightMsgUnjail int = 100 - DefaultWeightMsgCreateValidator int = 100 - DefaultWeightMsgEditValidator int = 5 - DefaultWeightMsgDelegate int = 100 - DefaultWeightMsgUndelegate int = 100 - DefaultWeightMsgBeginRedelegate int = 100 - DefaultWeightMsgCancelUnbondingDelegation int = 100 - - DefaultWeightCommunitySpendProposal int = 5 - DefaultWeightTextProposal int = 5 - DefaultWeightParamChangeProposal int = 5 - - // feegrant - DefaultWeightGrantAllowance int = 100 - DefaultWeightRevokeAllowance int = 100 -) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 1b363c2c3fc9..cee10e09ec5d 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -15,8 +15,11 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/depinject" "github.com/cosmos/cosmos-sdk/simapp" + storetypes "github.com/cosmos/cosmos-sdk/store/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -28,6 +31,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) @@ -81,28 +85,36 @@ type IntegrationTestSuite struct { StakingKeeper stakingkeeper.Keeper } -// func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) { -// // app := suite.app -// maccPerms := simapp.GetMaccPerms() -// appCodec := simapp.MakeTestEncodingConfig().Codec - -// maccPerms[holder] = nil -// maccPerms[authtypes.Burner] = []string{authtypes.Burner} -// maccPerms[authtypes.Minter] = []string{authtypes.Minter} -// maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} -// maccPerms[randomPerm] = []string{"random"} - -// authKeeper := authkeeper.NewAccountKeeper( -// appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName), -// authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, -// ) -// keeper := keeper.NewBaseKeeper( -// appCodec, app.GetKey(types.StoreKey), authKeeper, -// app.GetSubspace(types.ModuleName), blockedAddrs, -// ) - -// return authKeeper, keeper -// } +func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) { + // app := suite.app + maccPerms := simapp.GetMaccPerms() + + maccPerms[holder] = nil + maccPerms[authtypes.Burner] = []string{authtypes.Burner} + maccPerms[authtypes.Minter] = []string{authtypes.Minter} + maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} + maccPerms[randomPerm] = []string{"random"} + + var ( + keys map[string]*storetypes.KVStoreKey + paramKeeper paramskeeper.Keeper + appCodec codec.Codec + ) + + depinject.Inject(testutil.AppConfig, &appCodec, &suite.BankKeeper, &appCodec, &suite.AccountKeeper, ¶mKeeper, &keys) + + subSpace, _ := paramKeeper.GetSubspace(types.ModuleName) + authKeeper := authkeeper.NewAccountKeeper( + appCodec, app.GetKey(types.StoreKey), subSpace, + authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, + ) + keeper := keeper.NewBaseKeeper( + appCodec, app.GetKey(types.StoreKey), authKeeper, + subSpace, blockedAddrs, + ) + + return authKeeper, keeper +} func (suite *IntegrationTestSuite) SetupTest() { @@ -287,7 +299,7 @@ func (suite *IntegrationTestSuite) TestSupply_MintCoins() { func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { ctx := suite.ctx // add module accounts to supply keeper - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) + // authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) // set burnerAcc balance authKeeper.SetModuleAccount(ctx, burnerAcc) diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 6f973fff43e9..99126d1fd65e 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -8,7 +8,6 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp/helpers" - "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -21,8 +20,10 @@ import ( // Simulation operation weights constants //nolint:gosec // these are not hardcoded credentials. const ( - OpWeightMsgSend = "op_weight_msg_send" - OpWeightMsgMultiSend = "op_weight_msg_multisend" + OpWeightMsgSend = "op_weight_msg_send" + OpWeightMsgMultiSend = "op_weight_msg_multisend" + DefaultWeightMsgSend int = 100 + DefaultWeightMsgMultiSend int = 10 ) // WeightedOperations returns all the operations from the module with their respective weights @@ -33,13 +34,13 @@ func WeightedOperations( var weightMsgSend, weightMsgMultiSend int appParams.GetOrGenerate(cdc, OpWeightMsgSend, &weightMsgSend, nil, func(_ *rand.Rand) { - weightMsgSend = sims.DefaultWeightMsgSend + weightMsgSend = DefaultWeightMsgSend }, ) appParams.GetOrGenerate(cdc, OpWeightMsgMultiSend, &weightMsgMultiSend, nil, func(_ *rand.Rand) { - weightMsgMultiSend = sims.DefaultWeightMsgMultiSend + weightMsgMultiSend = DefaultWeightMsgMultiSend }, ) diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index 623c84e80487..d7fa8ec2b322 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/runtime" - "github.com/cosmos/cosmos-sdk/testutil/sims" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -67,8 +66,8 @@ func (suite *SimTestSuite) TestWeightedOperations() { opMsgRoute string opMsgName string }{ - {sims.DefaultWeightMsgSend, types.ModuleName, types.TypeMsgSend}, - {sims.DefaultWeightMsgMultiSend, types.ModuleName, types.TypeMsgMultiSend}, + {simulation.DefaultWeightMsgSend, types.ModuleName, types.TypeMsgSend}, + {simulation.DefaultWeightMsgMultiSend, types.ModuleName, types.TypeMsgMultiSend}, } for i, w := range weightesOps {