github.com/Finschia/finschia-sdk@v0.48.1/x/gov/simulation/params_test.go (about)

     1  package simulation_test
     2  
     3  import (
     4  	"math/rand"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"github.com/Finschia/finschia-sdk/x/gov/simulation"
    10  )
    11  
    12  func TestParamChanges(t *testing.T) {
    13  	s := rand.NewSource(1)
    14  	r := rand.New(s)
    15  
    16  	expected := []struct {
    17  		composedKey string
    18  		key         string
    19  		simValue    string
    20  		subspace    string
    21  	}{
    22  		{"gov/votingparams", "votingparams", "{\"voting_period\": \"82639000000000\"}", "gov"},
    23  		{"gov/depositparams", "depositparams", "{\"max_deposit_period\": \"47332000000000\"}", "gov"},
    24  		{"gov/tallyparams", "tallyparams", "{\"threshold\":\"0.509000000000000000\"}", "gov"},
    25  	}
    26  
    27  	paramChanges := simulation.ParamChanges(r)
    28  	require.Len(t, paramChanges, 3)
    29  
    30  	for i, p := range paramChanges {
    31  
    32  		require.Equal(t, expected[i].composedKey, p.ComposedKey())
    33  		require.Equal(t, expected[i].key, p.Key())
    34  		require.Equal(t, expected[i].simValue, p.SimValue()(r))
    35  		require.Equal(t, expected[i].subspace, p.Subspace())
    36  	}
    37  }