Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Jun 16, 2022
1 parent 90fa5ba commit 595d710
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 60 deletions.
29 changes: 0 additions & 29 deletions testutil/sims/weights.go

This file was deleted.

58 changes: 35 additions & 23 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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, &paramKeeper, &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() {

Expand Down Expand Up @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions x/bank/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
},
)

Expand Down
5 changes: 2 additions & 3 deletions x/bank/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 595d710

Please sign in to comment.