diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 88037046a69..12d7e70a147 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -3,11 +3,9 @@ package fee_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" @@ -25,27 +23,11 @@ type FeeTestSuite struct { path *ibctesting.Path } -// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *FeeTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) - path.EndpointA.ChannelConfig.Version = feeTransferVersion - path.EndpointB.ChannelConfig.Version = feeTransferVersion - path.EndpointA.ChannelConfig.PortID = transfertypes.PortID - path.EndpointB.ChannelConfig.PortID = transfertypes.PortID - suite.path = path -} - -// TODO: rename to 'SetupTest' when the above function is removed -func (suite *FeeTestSuite) SetupMockTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) path.EndpointA.ChannelConfig.Version = mockFeeVersion @@ -59,28 +41,6 @@ func TestIBCFeeTestSuite(t *testing.T) { suite.Run(t, new(FeeTestSuite)) } -// TODO: remove -func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet { - - fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData( - coin.Denom, - sdk.NewInt(100).String(), - suite.chainA.SenderAccount.GetAddress().String(), - suite.chainB.SenderAccount.GetAddress().String(), - ) - - return channeltypes.NewPacket( - fungibleTokenPacket.GetBytes(), - suite.chainA.SenderAccount.GetSequence(), - suite.path.EndpointA.ChannelConfig.PortID, - suite.path.EndpointA.ChannelID, - suite.path.EndpointB.ChannelConfig.PortID, - suite.path.EndpointB.ChannelID, - clienttypes.NewHeight(0, 100), - 0, - ) -} - func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { return channeltypes.NewPacket( ibcmock.MockPacketData, diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index b556f057d7e..2a9bf532767 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -59,7 +59,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { suite.Run(tc.name, func() { // reset suite - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) // setup mock callback @@ -150,7 +150,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { suite.Run(tc.name, func() { // reset suite - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) suite.path.EndpointB.ChanOpenInit() @@ -255,7 +255,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) // setup mock callback @@ -337,7 +337,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) @@ -415,7 +415,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) @@ -481,7 +481,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled @@ -724,7 +724,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) packet := suite.CreateMockPacket() diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index be49deef63b..3fbfa96406d 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" @@ -34,31 +33,11 @@ type KeeperTestSuite struct { queryClient types.QueryClient } -// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *KeeperTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) - path.EndpointA.ChannelConfig.Version = feeTransferVersion - path.EndpointB.ChannelConfig.Version = feeTransferVersion - path.EndpointA.ChannelConfig.PortID = transfertypes.PortID - path.EndpointB.ChannelConfig.PortID = transfertypes.PortID - suite.path = path - - queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) -} - -// TODO: rename to 'SetupTest' when the above function is removed -func (suite *KeeperTestSuite) SetupMockTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) path.EndpointA.ChannelConfig.Version = mockFeeVersion @@ -77,7 +56,6 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestFeeInEscrow() { - suite.SetupMockTest() suite.coordinator.Setup(suite.path) fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} @@ -119,7 +97,6 @@ func (suite *KeeperTestSuite) TestDisableAllChannels() { } func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { - suite.SetupMockTest() suite.coordinator.Setup(suite.path) // escrow a fee