forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparams_test.go
54 lines (42 loc) · 1.53 KB
/
params_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package simulation
import (
"fmt"
"math/rand"
"testing"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
)
func TestParamChange(t *testing.T) {
subspace, key := "theSubspace", "key"
f := func(r *rand.Rand) string {
return "theResult"
}
pChange := NewSimParamChange(subspace, key, f)
require.Equal(t, subspace, pChange.Subspace())
require.Equal(t, key, pChange.Key())
require.Equal(t, f(nil), pChange.SimValue()(nil))
require.Equal(t, fmt.Sprintf("%s/%s", subspace, key), pChange.ComposedKey())
}
func TestNewWeightedProposalContent(t *testing.T) {
key := "theKey"
weight := 1
content := &testContent{}
f := func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content {
return content
}
pContent := NewWeightedProposalContent(key, weight, f)
require.Equal(t, key, pContent.AppParamsKey())
require.Equal(t, weight, pContent.DefaultWeight())
ctx := sdk.NewContext(nil, tmproto.Header{}, true, nil)
require.Equal(t, content, pContent.ContentSimulatorFn()(nil, ctx, nil))
}
type testContent struct {
}
func (t testContent) GetTitle() string { return "" }
func (t testContent) GetDescription() string { return "" }
func (t testContent) ProposalRoute() string { return "" }
func (t testContent) ProposalType() string { return "" }
func (t testContent) ValidateBasic() error { return nil }
func (t testContent) String() string { return "" }