Skip to content

Commit 3ea70c5

Browse files
committed
add types_test.go
1 parent 12b2eb1 commit 3ea70c5

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

x/cronos/types/types_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package types
2+
3+
import (
4+
"github.com/stretchr/testify/require"
5+
"testing"
6+
)
7+
8+
func Test_IsValidIBCDenom(t *testing.T) {
9+
tests := []struct {
10+
name string
11+
denom string
12+
success bool
13+
}{
14+
{"wrong length", "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
15+
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865", false},
16+
{"correct IBC denom", IbcCroDenomDefaultValue, true},
17+
}
18+
for _, tt := range tests {
19+
tt := tt
20+
t.Run(tt.name, func(t *testing.T) {
21+
require.Equal(t, tt.success, IsValidIBCDenom(tt.denom))
22+
})
23+
}
24+
}
25+
26+
func Test_IsValidGravityDenom(t *testing.T) {
27+
tests := []struct {
28+
name string
29+
denom string
30+
success bool
31+
}{
32+
{"wrong length", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
33+
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", false},
34+
{"correct gravity denom", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", true},
35+
}
36+
for _, tt := range tests {
37+
tt := tt
38+
t.Run(tt.name, func(t *testing.T) {
39+
require.Equal(t, tt.success, IsValidGravityDenom(tt.denom))
40+
})
41+
}
42+
}
43+
44+
func Test_IsValidDenomToWrap(t *testing.T) {
45+
tests := []struct {
46+
name string
47+
denom string
48+
success bool
49+
}{
50+
{"wrong length", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
51+
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", false},
52+
{"correct gravity denom", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", true},
53+
{"wrong length", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
54+
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", false},
55+
{"correct gravity denom", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", true},
56+
}
57+
for _, tt := range tests {
58+
tt := tt
59+
t.Run(tt.name, func(t *testing.T) {
60+
require.Equal(t, tt.success, IsValidDenomToWrap(tt.denom))
61+
})
62+
}
63+
}

0 commit comments

Comments
 (0)