-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: define methods used for module simulation
- Loading branch information
1 parent
1f022bf
commit c9a9302
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package payment | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/x/authz/codec" | ||
"math/rand" | ||
|
||
paymentsimulation "github.com/celestiaorg/celestia-app/x/payment/simulation" | ||
"github.com/celestiaorg/celestia-app/x/payment/types" | ||
"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 ( | ||
_ = paymentsimulation.FindAccount | ||
_ = simappparams.StakePerAccount | ||
_ = simulation.MsgEntryKind | ||
_ = baseapp.Paramspace | ||
) | ||
|
||
const ( | ||
// this line is used by starport scaffolding # simapp/module/const | ||
) | ||
|
||
// 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() | ||
} | ||
loanGenesis := types.GenesisState{ | ||
Params: types.DefaultParams(), | ||
// this line is used by starport scaffolding # simapp/module/genesisState | ||
} | ||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&loanGenesis) | ||
} | ||
|
||
// 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 { | ||
paymentParams := types.DefaultParams() | ||
return []simtypes.ParamChange{ | ||
simulation.NewSimParamChange(types.ModuleName, string(types.KeyMinSquareSize), func(r *rand.Rand) string { | ||
return string(codec.Amino.MustMarshalJSON(paymentParams.MinSquareSize)) | ||
}), | ||
simulation.NewSimParamChange(types.ModuleName, string(types.KeyMaxSquareSize), func(r *rand.Rand) string { | ||
return string(codec.Amino.MustMarshalJSON(paymentParams.MaxSquareSize)) | ||
}), | ||
} | ||
} | ||
|
||
// 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) | ||
|
||
// this line is used by starport scaffolding # simapp/module/operation | ||
|
||
return operations | ||
} |