client_test.gno
0.95 Kb · 36 lines
1package types_test
2
3import (
4 "testing"
5
6 "gno.land/p/aib/ibc/types"
7 "gno.land/p/nt/urequire/v0"
8)
9
10func TestValidateClientType(t *testing.T) {
11 testCases := []struct {
12 name string
13 clientType string
14 expError string
15 }{
16 {"valid", "tendermint", ""},
17 {"valid solomachine", "solomachine-v1", ""},
18 {"too large", "tenderminttenderminttenderminttenderminttendermintt", "invalid length: 72, must be between 4-64 characters"},
19 {"too short", "t", "invalid length: 3, must be between 4-64 characters"},
20 {"blank id", " ", "client type cannot be blank"},
21 {"empty id", "", "client type cannot be blank"},
22 {"ends with dash", "tendermint-", "not a valid clientID: tendermint--0"},
23 }
24
25 for _, tc := range testCases {
26 t.Run(tc.name, func(t *testing.T) {
27 err := types.ValidateClientType(tc.clientType)
28
29 if tc.expError == "" {
30 urequire.NoError(t, err, tc.name)
31 } else {
32 urequire.ErrorContains(t, err, tc.expError)
33 }
34 })
35 }
36}