cosmos-sdk/baseapp/params_test.go
Aleksandr Bezobchuk af8ad3d20d
chore: bump TM to v0.35.0 release candidate (#10210)
Integrate Tendermint v0.35.0, including changes to build and test
plumbing necessary to make everything build. This change does not
update any SDK APIs to make use of new features.

Co-authored-by: marbar3778 <marbar3778@yahoo.com>
Co-authored-by: tycho garen <garen@tychoish.com>
Co-authored-by: M. J. Fromberger <michael.j.fromberger@gmail.com>
Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
Co-authored-by: Callum Waters <cmwaters19@gmail.com>
2021-11-16 11:24:38 -08:00

66 lines
1.9 KiB
Go

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)
}
}