aboutsummaryrefslogtreecommitdiffstats
path: root/simulation/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'simulation/utils.go')
-rw-r--r--simulation/utils.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/simulation/utils.go b/simulation/utils.go
index a18e8a4..a305d2b 100644
--- a/simulation/utils.go
+++ b/simulation/utils.go
@@ -20,6 +20,9 @@ package simulation
import (
"math"
"sort"
+
+ "github.com/dexon-foundation/dexon-consensus/core/test"
+ "github.com/dexon-foundation/dexon-consensus/simulation/config"
)
func calculateMeanStdDeviationFloat64s(a []float64) (float64, float64) {
@@ -57,3 +60,18 @@ func getMinMedianMaxFloat64s(a []float64) (float64, float64, float64) {
sort.Float64s(aCopied)
return aCopied[0], aCopied[len(aCopied)/2], aCopied[len(aCopied)-1]
}
+
+func prepareConfigs(
+ round uint64, cfgs []config.Change, gov *test.Governance) {
+ for _, c := range cfgs {
+ if c.Round != round {
+ continue
+ }
+ t := config.StateChangeTypeFromString(c.Type)
+ if err := gov.State().RequestChange(
+ t, config.StateChangeValueFromString(t, c.Value)); err != nil {
+ panic(err)
+ }
+ }
+ gov.CatchUpWithRound(round)
+}