From b3838394e73e0abab76035f02e444f40dade3b4f Mon Sep 17 00:00:00 2001 From: dauTT Date: Sun, 19 Jul 2020 23:57:14 +0200 Subject: [PATCH] x/gov/simulation/params.go: add unit tests (#6738) Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> --- x/gov/simulation/params_test.go | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 x/gov/simulation/params_test.go diff --git a/x/gov/simulation/params_test.go b/x/gov/simulation/params_test.go new file mode 100644 index 000000000..de528d14d --- /dev/null +++ b/x/gov/simulation/params_test.go @@ -0,0 +1,37 @@ +package simulation_test + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/x/gov/simulation" +) + +func TestParamChanges(t *testing.T) { + s := rand.NewSource(1) + r := rand.New(s) + + expected := []struct { + composedKey string + key string + simValue string + subspace string + }{ + {"gov/votingparams", "votingparams", "{\"voting_period\": \"82639000000000\"}", "gov"}, + {"gov/depositparams", "depositparams", "{\"max_deposit_period\": \"47332000000000\"}", "gov"}, + {"gov/tallyparams", "tallyparams", "{\"threshold\":\"0.509000000000000000\"}", "gov"}, + } + + paramChanges := simulation.ParamChanges(r) + require.Len(t, paramChanges, 3) + + for i, p := range paramChanges { + + require.Equal(t, expected[i].composedKey, p.ComposedKey()) + require.Equal(t, expected[i].key, p.Key()) + require.Equal(t, expected[i].simValue, p.SimValue()(r)) + require.Equal(t, expected[i].subspace, p.Subspace()) + } +}