gpu-compute-chain/x/colinearcore/module_simulation.go

141 lines
4.6 KiB
Go
Raw Normal View History

package colinearcore
2022-08-25 16:51:14 -07:00
import (
"math/rand"
"colinear/testutil/sample"
2022-09-07 13:25:57 -07:00
colinearcoresimulation "colinear/x/colinearcore/simulation"
2022-09-06 15:18:09 -07:00
"colinear/x/colinearcore/types"
2022-08-25 16:51:14 -07:00
"github.com/cosmos/cosmos-sdk/baseapp"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
)
// avoid unused import issue
var (
_ = sample.AccAddress
2022-09-07 13:25:57 -07:00
_ = colinearcoresimulation.FindAccount
2022-08-25 16:51:14 -07:00
_ = simappparams.StakePerAccount
_ = simulation.MsgEntryKind
_ = baseapp.Paramspace
)
const (
2022-08-27 14:19:03 -07:00
opWeightMsgNewAuction = "op_weight_msg_new_auction"
// TODO: Determine the simulation weight value
defaultWeightMsgNewAuction int = 100
2022-08-28 10:57:06 -07:00
opWeightMsgNewBid = "op_weight_msg_new_bid"
// TODO: Determine the simulation weight value
defaultWeightMsgNewBid int = 100
2022-09-07 13:25:57 -07:00
opWeightMsgLockFunds = "op_weight_msg_lock_funds"
// TODO: Determine the simulation weight value
defaultWeightMsgLockFunds int = 100
2022-09-08 14:49:56 -07:00
opWeightMsgUnlockFunds = "op_weight_msg_unlock_funds"
// TODO: Determine the simulation weight value
defaultWeightMsgUnlockFunds int = 100
2022-09-08 16:29:08 -07:00
opWeightMsgUnlockAllFunds = "op_weight_msg_unlock_all_funds"
// TODO: Determine the simulation weight value
defaultWeightMsgUnlockAllFunds int = 100
2022-08-27 14:19:03 -07:00
// this line is used by starport scaffolding # simapp/module/const
2022-08-25 16:51:14 -07:00
)
// GenerateGenesisState creates a randomized GenState of the module
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
accs := make([]string, len(simState.Accounts))
for i, acc := range simState.Accounts {
accs[i] = acc.Address.String()
}
colinearGenesis := types.GenesisState{
2022-08-25 16:51:14 -07:00
Params: types.DefaultParams(),
// this line is used by starport scaffolding # simapp/module/genesisState
}
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&colinearGenesis)
2022-08-25 16:51:14 -07:00
}
// ProposalContents doesn't return any content functions for governance proposals
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
return nil
}
// RandomizedParams creates randomized param changes for the simulator
func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return []simtypes.ParamChange{}
}
// RegisterStoreDecoder registers a decoder
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
// WeightedOperations returns the all the gov module operations with their respective weights.
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
operations := make([]simtypes.WeightedOperation, 0)
2022-08-27 14:19:03 -07:00
var weightMsgNewAuction int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgNewAuction, &weightMsgNewAuction, nil,
func(_ *rand.Rand) {
weightMsgNewAuction = defaultWeightMsgNewAuction
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgNewAuction,
2022-09-07 13:25:57 -07:00
colinearcoresimulation.SimulateMsgNewAuction(am.accountKeeper, am.bankKeeper, am.keeper),
2022-08-27 14:19:03 -07:00
))
2022-08-28 10:57:06 -07:00
var weightMsgNewBid int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgNewBid, &weightMsgNewBid, nil,
func(_ *rand.Rand) {
weightMsgNewBid = defaultWeightMsgNewBid
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgNewBid,
2022-09-07 13:25:57 -07:00
colinearcoresimulation.SimulateMsgNewBid(am.accountKeeper, am.bankKeeper, am.keeper),
))
var weightMsgLockFunds int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgLockFunds, &weightMsgLockFunds, nil,
func(_ *rand.Rand) {
weightMsgLockFunds = defaultWeightMsgLockFunds
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgLockFunds,
colinearcoresimulation.SimulateMsgLockFunds(am.accountKeeper, am.bankKeeper, am.keeper),
2022-08-28 10:57:06 -07:00
))
2022-09-08 14:49:56 -07:00
var weightMsgUnlockFunds int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUnlockFunds, &weightMsgUnlockFunds, nil,
func(_ *rand.Rand) {
weightMsgUnlockFunds = defaultWeightMsgUnlockFunds
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUnlockFunds,
colinearcoresimulation.SimulateMsgUnlockFunds(am.accountKeeper, am.bankKeeper, am.keeper),
))
2022-09-08 16:29:08 -07:00
var weightMsgUnlockAllFunds int
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUnlockAllFunds, &weightMsgUnlockAllFunds, nil,
func(_ *rand.Rand) {
weightMsgUnlockAllFunds = defaultWeightMsgUnlockAllFunds
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgUnlockAllFunds,
colinearcoresimulation.SimulateMsgUnlockAllFunds(am.accountKeeper, am.bankKeeper, am.keeper),
))
2022-08-25 16:51:14 -07:00
// this line is used by starport scaffolding # simapp/module/operation
return operations
}