store_test.gno
1.12 Kb · 58 lines
1package transfer
2
3import (
4 "testing"
5
6 "gno.land/p/nt/uassert/v0"
7)
8
9func TestGRC20AliasRoundTrip(t *testing.T) {
10 testCases := []struct {
11 name string
12 key string
13 expAlias string
14 }{
15 {
16 "simple path without slug",
17 "gno.land/r/demo/foo",
18 "gno.land:r:demo:foo",
19 },
20 {
21 "path with slug",
22 "gno.land/r/demo/foo.FOO",
23 "gno.land:r:demo:foo.FOO",
24 },
25 {
26 "path with alphanumeric slug",
27 "gno.land/r/demo/foo.Bar123",
28 "gno.land:r:demo:foo.Bar123",
29 },
30 }
31 for _, tc := range testCases {
32 t.Run(tc.name, func(t *testing.T) {
33 alias := GRC20Alias(tc.key)
34 uassert.Equal(t, tc.expAlias, alias)
35
36 got := resolveGRC20Alias(alias)
37 uassert.Equal(t, tc.key, got)
38 })
39 }
40}
41
42func TestIsGRC20Alias(t *testing.T) {
43 testCases := []struct {
44 name string
45 denom string
46 expect bool
47 }{
48 {"grc20 alias", "gno.land:r:demo:foo.FOO", true},
49 {"native denom", "ugnot", false},
50 {"ibc denom", "ibc/ABC123", false},
51 {"gno path not aliased", "gno.land/r/demo/foo", false},
52 }
53 for _, tc := range testCases {
54 t.Run(tc.name, func(t *testing.T) {
55 uassert.Equal(t, tc.expect, isGRC20Alias(tc.denom))
56 })
57 }
58}