github.com/cosmos/cosmos-sdk@v0.50.10/x/auth/types/params_test.go (about) 1 package types_test 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/require" 8 9 "github.com/cosmos/cosmos-sdk/x/auth/types" 10 ) 11 12 func TestParamsEqual(t *testing.T) { 13 p1 := types.DefaultParams() 14 p2 := types.DefaultParams() 15 require.Equal(t, p1, p2) 16 17 p1.TxSigLimit += 10 18 require.NotEqual(t, p1, p2) 19 } 20 21 func TestParams_Validate(t *testing.T) { 22 tests := []struct { 23 name string 24 params types.Params 25 wantErr error 26 }{ 27 {"default params", types.DefaultParams(), nil}, 28 {"invalid tx signature limit", types.NewParams(types.DefaultMaxMemoCharacters, 0, types.DefaultTxSizeCostPerByte, 29 types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx signature limit: 0")}, 30 {"invalid ED25519 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, 31 0, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid ED25519 signature verification cost: 0")}, 32 {"invalid SECK256k1 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, 33 types.DefaultSigVerifyCostED25519, 0), fmt.Errorf("invalid SECK256k1 signature verification cost: 0")}, 34 {"invalid max memo characters", types.NewParams(0, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, 35 types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid max memo characters: 0")}, 36 {"invalid tx size cost per byte", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 0, 37 types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx size cost per byte: 0")}, 38 } 39 for _, tt := range tests { 40 tt := tt 41 t.Run(tt.name, func(t *testing.T) { 42 got := tt.params.Validate() 43 if tt.wantErr == nil { 44 require.NoError(t, got) 45 return 46 } 47 48 require.NotEmpty(t, tt.params.String()) 49 require.Equal(t, tt.wantErr, got) 50 }) 51 } 52 }