|
6 | 6 | sdk "github.com/cosmos/cosmos-sdk/types"
|
7 | 7 | capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
8 | 8 |
|
| 9 | + fee "github.com/cosmos/ibc-go/v3/modules/apps/29-fee" |
9 | 10 | "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"
|
10 | 11 | transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
|
11 | 12 | channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
|
@@ -834,3 +835,78 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() {
|
834 | 835 | })
|
835 | 836 | }
|
836 | 837 | }
|
| 838 | + |
| 839 | +func (suite *FeeTestSuite) TestGetAppVersion() { |
| 840 | + var ( |
| 841 | + portID string |
| 842 | + channelID string |
| 843 | + expAppVersion string |
| 844 | + ) |
| 845 | + testCases := []struct { |
| 846 | + name string |
| 847 | + malleate func() |
| 848 | + expFound bool |
| 849 | + }{ |
| 850 | + { |
| 851 | + "success for fee enabled channel", |
| 852 | + func() { |
| 853 | + expAppVersion = ibcmock.Version |
| 854 | + }, |
| 855 | + true, |
| 856 | + }, |
| 857 | + { |
| 858 | + "success for non fee enabled channel", |
| 859 | + func() { |
| 860 | + path := ibctesting.NewPath(suite.chainA, suite.chainB) |
| 861 | + path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort |
| 862 | + path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort |
| 863 | + // by default a new path uses a non fee channel |
| 864 | + suite.coordinator.Setup(path) |
| 865 | + portID = path.EndpointA.ChannelConfig.PortID |
| 866 | + channelID = path.EndpointA.ChannelID |
| 867 | + |
| 868 | + expAppVersion = ibcmock.Version |
| 869 | + }, |
| 870 | + true, |
| 871 | + }, |
| 872 | + { |
| 873 | + "channel does not exist", |
| 874 | + func() { |
| 875 | + channelID = "does not exist" |
| 876 | + }, |
| 877 | + false, |
| 878 | + }, |
| 879 | + } |
| 880 | + |
| 881 | + for _, tc := range testCases { |
| 882 | + tc := tc |
| 883 | + suite.Run(tc.name, func() { |
| 884 | + suite.SetupTest() |
| 885 | + suite.coordinator.Setup(suite.path) |
| 886 | + |
| 887 | + portID = suite.path.EndpointA.ChannelConfig.PortID |
| 888 | + channelID = suite.path.EndpointA.ChannelID |
| 889 | + |
| 890 | + // malleate test case |
| 891 | + tc.malleate() |
| 892 | + |
| 893 | + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) |
| 894 | + suite.Require().NoError(err) |
| 895 | + |
| 896 | + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) |
| 897 | + suite.Require().True(ok) |
| 898 | + |
| 899 | + feeModule := cbs.(fee.IBCModule) |
| 900 | + |
| 901 | + appVersion, found := feeModule.GetAppVersion(suite.chainA.GetContext(), portID, channelID) |
| 902 | + |
| 903 | + if tc.expFound { |
| 904 | + suite.Require().True(found) |
| 905 | + suite.Require().Equal(expAppVersion, appVersion) |
| 906 | + } else { |
| 907 | + suite.Require().False(found) |
| 908 | + suite.Require().Empty(appVersion) |
| 909 | + } |
| 910 | + }) |
| 911 | + } |
| 912 | +} |
0 commit comments