mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-01-14 17:25:17 +00:00
36 lines
986 B
Go
36 lines
986 B
Go
package simulation
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
|
|
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
|
"github.com/cosmos/cosmos-sdk/x/simulation"
|
|
|
|
"github.com/0glabs/0g-chain/x/kavadist/types"
|
|
)
|
|
|
|
// ParamChanges defines the parameters that can be modified by param change proposals
|
|
// on the simulation
|
|
func ParamChanges(r *rand.Rand) []simtypes.ParamChange {
|
|
// Hacky way to validate periods since validation is wrapped in params
|
|
active := genRandomActive(r)
|
|
periods := genRandomPeriods(r, simtypes.RandTimestamp(r))
|
|
if err := types.NewParams(active, periods, types.DefaultInfraParams).Validate(); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return []simtypes.ParamChange{
|
|
simulation.NewSimParamChange(types.ModuleName, string(types.KeyActive),
|
|
func(r *rand.Rand) string {
|
|
return fmt.Sprintf("%t", active)
|
|
},
|
|
),
|
|
simulation.NewSimParamChange(types.ModuleName, string(types.KeyPeriods),
|
|
func(r *rand.Rand) string {
|
|
return fmt.Sprintf("%v", periods)
|
|
},
|
|
),
|
|
}
|
|
}
|