-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
212 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package provider_test | ||
|
||
import ( | ||
"testing" | ||
|
||
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" | ||
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" | ||
"github.com/cosmos/interchain-security/v4/x/ccv/provider" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
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 destination port and channel 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", | ||
}, | ||
} | ||
|
||
channeltypes.NewPacket( | ||
[]byte{}, | ||
0, | ||
"srcPort", | ||
"srcChannel", | ||
"dstPort", | ||
"dstChannel", | ||
clienttypes.NewHeight(1, 1), | ||
0, | ||
) | ||
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) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters