Skip to content

Commit

Permalink
add types_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy committed Sep 8, 2021
1 parent 12b2eb1 commit 3ea70c5
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions x/cronos/types/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package types

import (
"github.com/stretchr/testify/require"
"testing"
)

func Test_IsValidIBCDenom(t *testing.T) {
tests := []struct {
name string
denom string
success bool
}{
{"wrong length", "ibc/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD5D19762F541EC971ACB0865", false},
{"correct IBC denom", IbcCroDenomDefaultValue, true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.success, IsValidIBCDenom(tt.denom))
})
}
}

func Test_IsValidGravityDenom(t *testing.T) {
tests := []struct {
name string
denom string
success bool
}{
{"wrong length", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", false},
{"correct gravity denom", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.success, IsValidGravityDenom(tt.denom))
})
}
}

func Test_IsValidDenomToWrap(t *testing.T) {
tests := []struct {
name string
denom string
success bool
}{
{"wrong length", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", false},
{"correct gravity denom", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", true},
{"wrong length", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242FBD", false},
{"invalid denom", "aaa/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", false},
{"correct gravity denom", "gravity0x/6B5A664BF0AF4F71B2F0BAA33141E2F1321242F", true},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.success, IsValidDenomToWrap(tt.denom))
})
}
}

0 comments on commit 3ea70c5

Please sign in to comment.