cosmos-sdk/x/gov/simulation/proposals.go
mergify[bot] 826d4d3f28
refactor(sims)!: Remove Baseapp from sims (backport #21039) (#21058)
Co-authored-by: Alexander Peters <alpe@users.noreply.github.com>
2024-07-24 18:19:32 +02:00

57 lines
1.6 KiB
Go

package simulation
import (
"context"
"math/rand"
coreaddress "cosmossdk.io/core/address"
"cosmossdk.io/x/gov/types/v1beta1"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
)
// OpWeightSubmitTextProposal app params key for text proposal
const OpWeightSubmitTextProposal = "op_weight_submit_text_proposal"
// ProposalMsgs defines the module weighted proposals' contents
func ProposalMsgs() []simtypes.WeightedProposalMsg {
return []simtypes.WeightedProposalMsg{
simulation.NewWeightedProposalMsgX(
OpWeightSubmitTextProposal,
DefaultWeightTextProposal,
SimulateTextProposal,
),
}
}
// SimulateTextProposal returns a random text proposal content.
// A text proposal is a proposal that contains no msgs.
func SimulateTextProposal(_ context.Context, r *rand.Rand, _ []simtypes.Account, _ coreaddress.Codec) (sdk.Msg, error) {
return nil, nil
}
// ProposalContents defines the module weighted proposals' contents
//
//nolint:staticcheck // used for legacy testing
func ProposalContents() []simtypes.WeightedProposalContent {
return []simtypes.WeightedProposalContent{
simulation.NewWeightedProposalContent(
OpWeightMsgDeposit,
DefaultWeightTextProposal,
SimulateLegacyTextProposalContent,
),
}
}
// SimulateTextProposalContent returns a random text proposal content.
//
//nolint:staticcheck // used for legacy testing
func SimulateLegacyTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) simtypes.Content {
return v1beta1.NewTextProposal(
simtypes.RandStringOfLength(r, 140),
simtypes.RandStringOfLength(r, 5000),
)
}