github.com/cosmos/cosmos-sdk@v0.50.10/x/staking/simulation/proposals.go (about)

     1  package simulation
     2  
     3  import (
     4  	"math/rand"
     5  	"time"
     6  
     7  	sdkmath "cosmossdk.io/math"
     8  
     9  	sdk "github.com/cosmos/cosmos-sdk/types"
    10  	"github.com/cosmos/cosmos-sdk/types/address"
    11  	simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
    12  	"github.com/cosmos/cosmos-sdk/x/simulation"
    13  	"github.com/cosmos/cosmos-sdk/x/staking/types"
    14  )
    15  
    16  // Simulation operation weights constants
    17  const (
    18  	DefaultWeightMsgUpdateParams int = 100
    19  
    20  	OpWeightMsgUpdateParams = "op_weight_msg_update_params"
    21  )
    22  
    23  // ProposalMsgs defines the module weighted proposals' contents
    24  func ProposalMsgs() []simtypes.WeightedProposalMsg {
    25  	return []simtypes.WeightedProposalMsg{
    26  		simulation.NewWeightedProposalMsg(
    27  			OpWeightMsgUpdateParams,
    28  			DefaultWeightMsgUpdateParams,
    29  			SimulateMsgUpdateParams,
    30  		),
    31  	}
    32  }
    33  
    34  // SimulateMsgUpdateParams returns a random MsgUpdateParams
    35  func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg {
    36  	// use the default gov module account address as authority
    37  	var authority sdk.AccAddress = address.Module("gov")
    38  
    39  	params := types.DefaultParams()
    40  	params.BondDenom = simtypes.RandStringOfLength(r, 10)
    41  	params.HistoricalEntries = uint32(simtypes.RandIntBetween(r, 0, 1000))
    42  	params.MaxEntries = uint32(simtypes.RandIntBetween(r, 1, 1000))
    43  	params.MaxValidators = uint32(simtypes.RandIntBetween(r, 1, 1000))
    44  	params.UnbondingTime = time.Duration(simtypes.RandTimestamp(r).UnixNano())
    45  	params.MinCommissionRate = simtypes.RandomDecAmount(r, sdkmath.LegacyNewDec(1))
    46  
    47  	return &types.MsgUpdateParams{
    48  		Authority: authority.String(),
    49  		Params:    params,
    50  	}
    51  }