2020-04-24 15:20:34 +00:00
|
|
|
package simulation
|
|
|
|
|
|
|
|
import (
|
2020-04-24 21:55:18 +00:00
|
|
|
"fmt"
|
2020-04-24 15:20:34 +00:00
|
|
|
"math/rand"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/simulation"
|
2020-04-24 21:55:18 +00:00
|
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
2020-04-24 15:20:34 +00:00
|
|
|
)
|
|
|
|
|
2020-04-24 21:55:18 +00:00
|
|
|
const (
|
|
|
|
keyActive = "Active"
|
|
|
|
keyRewards = "Rewards"
|
|
|
|
)
|
|
|
|
|
|
|
|
// genActive generates active bool with 80% chance of true
|
|
|
|
func genActive(r *rand.Rand) bool {
|
|
|
|
threshold := 80
|
|
|
|
value := simulation.RandIntBetween(r, 1, 100)
|
|
|
|
if value > threshold {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2020-04-24 15:20:34 +00:00
|
|
|
// ParamChanges defines the parameters that can be modified by param change proposals
|
|
|
|
func ParamChanges(r *rand.Rand) []simulation.ParamChange {
|
2020-04-24 21:55:18 +00:00
|
|
|
return []simulation.ParamChange{
|
|
|
|
simulation.NewSimParamChange(types.ModuleName, keyActive,
|
|
|
|
func(r *rand.Rand) string {
|
|
|
|
return fmt.Sprintf("\"%t\"", genActive(r))
|
|
|
|
},
|
|
|
|
),
|
|
|
|
simulation.NewSimParamChange(types.ModuleName, keyRewards,
|
|
|
|
func(r *rand.Rand) string {
|
|
|
|
return fmt.Sprintf("\"%v\"", genRewards(r))
|
|
|
|
},
|
|
|
|
),
|
|
|
|
}
|
2020-04-24 15:20:34 +00:00
|
|
|
}
|