forked from cosmos/interchain-security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibc_middleware_test.go
77 lines (71 loc) · 1.69 KB
/
ibc_middleware_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package provider_test
import (
"testing"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
"github.com/stretchr/testify/require"
"github.com/cosmos/interchain-security/v6/x/ccv/provider"
)
func TestGetProviderDenom(t *testing.T) {
testCases := []struct {
name string
denom string
packet channeltypes.Packet
expProviderDenom string
}{
{
name: "returns base denom with destination port and channel as prefix",
denom: "stake",
packet: channeltypes.NewPacket(
[]byte{},
0,
"srcPort",
"srcChannel",
"dstPort",
"dstChannel",
clienttypes.NewHeight(1, 1),
0,
),
expProviderDenom: "dstPort/dstChannel/stake",
},
{
name: "returns base denom if the prefix denom corresponds to the packet's port and channel source",
denom: "srcPort/srcChannel/stake",
packet: channeltypes.NewPacket(
[]byte{},
0,
"srcPort",
"srcChannel",
"dstPort",
"dstChannel",
clienttypes.NewHeight(1, 1),
0,
),
expProviderDenom: "stake",
},
{
name: "returns prefixed denom updated with packet's port and channel destination as prefix",
denom: "dstPort/dstChannel/stake",
packet: channeltypes.NewPacket(
[]byte{},
0,
"srcPort",
"srcChannel",
"dstPort",
"dstChannel",
clienttypes.NewHeight(1, 1),
0,
),
expProviderDenom: "dstPort/dstChannel/dstPort/dstChannel/stake",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
res := provider.GetProviderDenom(
tc.denom,
tc.packet,
)
require.Equal(t, tc.expProviderDenom, res)
})
}
}