From 41549becfe99c0d3ae593d875f2ac2cfde396e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 16 Feb 2022 13:07:29 +0100 Subject: [PATCH] refactor: OnRecvPacket to use mock module --- modules/apps/29-fee/fee_test.go | 13 +++++++++++++ modules/apps/29-fee/ibc_module_test.go | 16 ++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 6df368364bf..88037046a69 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -80,3 +80,16 @@ func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet 0, ) } + +func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { + return channeltypes.NewPacket( + ibcmock.MockPacketData, + 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, + ) +} diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 8f1e4ad1f28..d838138b2dc 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -466,21 +466,18 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.Setup(suite.path) - // set up coin & ics20 packet - coin := ibctesting.TestCoin - // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled suite.path.EndpointB.ChannelID = "channel-1" suite.chainB.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, "channel-0") - packet := suite.CreateICS20Packet(coin) + packet := suite.CreateMockPacket() // set up module and callbacks - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) @@ -495,19 +492,18 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { switch { case !tc.feeEnabled: - ack := channeltypes.NewResultAcknowledgement([]byte{1}) - suite.Require().Equal(ack, result) + suite.Require().Equal(ibcmock.MockAcknowledgement, result) case tc.forwardRelayer: ack := types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: suite.chainB.SenderAccount.GetAddress().String(), } suite.Require().Equal(ack, result) case !tc.forwardRelayer: ack := types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: "", } suite.Require().Equal(ack, result)