forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
params_test.go
65 lines (56 loc) · 1.94 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
55
56
57
58
59
60
61
62
63
64
65
package baseapp_test
import (
"testing"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/baseapp"
)
func TestValidateBlockParams(t *testing.T) {
testCases := []struct {
arg interface{}
expectErr bool
}{
{nil, true},
{&tmproto.BlockParams{}, true},
{tmproto.BlockParams{}, true},
{tmproto.BlockParams{MaxBytes: -1, MaxGas: -1}, true},
{tmproto.BlockParams{MaxBytes: 2000000, MaxGas: -5}, true},
{tmproto.BlockParams{MaxBytes: 2000000, MaxGas: 300000}, false},
}
for _, tc := range testCases {
require.Equal(t, tc.expectErr, baseapp.ValidateBlockParams(tc.arg) != nil)
}
}
func TestValidateEvidenceParams(t *testing.T) {
testCases := []struct {
arg interface{}
expectErr bool
}{
{nil, true},
{&tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1, MaxBytes: 5000000}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: -1}, true},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 5000000}, false},
{tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 0}, false},
}
for _, tc := range testCases {
require.Equal(t, tc.expectErr, baseapp.ValidateEvidenceParams(tc.arg) != nil)
}
}
func TestValidateValidatorParams(t *testing.T) {
testCases := []struct {
arg interface{}
expectErr bool
}{
{nil, true},
{&tmproto.ValidatorParams{}, true},
{tmproto.ValidatorParams{}, true},
{tmproto.ValidatorParams{PubKeyTypes: []string{}}, true},
{tmproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false},
}
for _, tc := range testCases {
require.Equal(t, tc.expectErr, baseapp.ValidateValidatorParams(tc.arg) != nil)
}
}