Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix experror in param test #7731

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions modules/core/02-client/types/params_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
"errors"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -31,26 +32,27 @@ func TestIsAllowedClient(t *testing.T) {

func TestValidateParams(t *testing.T) {
testCases := []struct {
name string
params Params
expPass bool
name string
params Params
expError error
}{
{"default params", DefaultParams(), true},
{"custom params", NewParams(exported.Tendermint), true},
{"blank client", NewParams(" "), false},
{"duplicate clients", NewParams(exported.Tendermint, exported.Tendermint), false},
{"allow all clients plus valid client", NewParams(AllowAllClients, exported.Tendermint), false},
{"too many allowed clients", NewParams(make([]string, MaxAllowedClientsLength+1)...), false},
{"default params", DefaultParams(), nil},
{"custom params", NewParams(exported.Tendermint), nil},
{"blank client", NewParams(" "), errors.New("client type 0 cannot be blank")},
{"duplicate clients", NewParams(exported.Tendermint, exported.Tendermint), errors.New("duplicate client type: 07-tendermint")},
{"allow all clients plus valid client", NewParams(AllowAllClients, exported.Tendermint), errors.New("allow list must have only one element because the allow all clients wildcard (*) is present")},
{"too many allowed clients", NewParams(make([]string, MaxAllowedClientsLength+1)...), errors.New("allowed clients length must not exceed 200 items")},
}

for _, tc := range testCases {
tc := tc

err := tc.params.Validate()
if tc.expPass {
if tc.expError == nil {
require.NoError(t, err, tc.name)
} else {
require.Error(t, err, tc.name)
require.ErrorContains(t, err, tc.expError.Error())
}
}
}
Loading