github.com/Finschia/finschia-sdk@v0.48.1/baseapp/params_test.go (about) 1 package baseapp_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 abci "github.com/tendermint/tendermint/abci/types" 8 tmproto "github.com/tendermint/tendermint/proto/tendermint/types" 9 10 "github.com/Finschia/finschia-sdk/baseapp" 11 ) 12 13 func TestValidateBlockParams(t *testing.T) { 14 testCases := []struct { 15 arg interface{} 16 expectErr bool 17 }{ 18 {nil, true}, 19 {&abci.BlockParams{}, true}, 20 {abci.BlockParams{}, true}, 21 {abci.BlockParams{MaxBytes: -1, MaxGas: -1}, true}, 22 {abci.BlockParams{MaxBytes: 2000000, MaxGas: -5}, true}, 23 {abci.BlockParams{MaxBytes: 2000000, MaxGas: 300000}, false}, 24 } 25 26 for _, tc := range testCases { 27 require.Equal(t, tc.expectErr, baseapp.ValidateBlockParams(tc.arg) != nil) 28 } 29 } 30 31 func TestValidateEvidenceParams(t *testing.T) { 32 testCases := []struct { 33 arg interface{} 34 expectErr bool 35 }{ 36 {nil, true}, 37 {&tmproto.EvidenceParams{}, true}, 38 {tmproto.EvidenceParams{}, true}, 39 {tmproto.EvidenceParams{MaxAgeNumBlocks: -1, MaxAgeDuration: 18004000, MaxBytes: 5000000}, true}, 40 {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: -1, MaxBytes: 5000000}, true}, 41 {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: -1}, true}, 42 {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 5000000}, false}, 43 {tmproto.EvidenceParams{MaxAgeNumBlocks: 360000, MaxAgeDuration: 18004000, MaxBytes: 0}, false}, 44 } 45 46 for _, tc := range testCases { 47 require.Equal(t, tc.expectErr, baseapp.ValidateEvidenceParams(tc.arg) != nil) 48 } 49 } 50 51 func TestValidateValidatorParams(t *testing.T) { 52 testCases := []struct { 53 arg interface{} 54 expectErr bool 55 }{ 56 {nil, true}, 57 {&tmproto.ValidatorParams{}, true}, 58 {tmproto.ValidatorParams{}, true}, 59 {tmproto.ValidatorParams{PubKeyTypes: []string{}}, true}, 60 {tmproto.ValidatorParams{PubKeyTypes: []string{"secp256k1"}}, false}, 61 {tmproto.ValidatorParams{PubKeyTypes: []string{"invalidPubKeyType"}}, true}, 62 } 63 64 for _, tc := range testCases { 65 require.Equal(t, tc.expectErr, baseapp.ValidateValidatorParams(tc.arg) != nil) 66 } 67 }