Skip to content

Commit

Permalink
refactor: use mock module for OnAcknowledgePacket callback testing (#929
Browse files Browse the repository at this point in the history
)

Co-authored-by: Sean King <seantking@users.noreply.github.com>
  • Loading branch information
colin-axner and seantking authored Feb 21, 2022
1 parent 4326c14 commit ad7827f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions modules/apps/29-fee/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId)

ack = types.IncentivizedAcknowledgement{
Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(),
Result: ibcmock.MockAcknowledgement.Acknowledgement(),
ForwardRelayerAddress: suite.chainA.SenderAccount.GetAddress().String(),
}.Acknowledgement()

Expand All @@ -578,7 +578,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
"channel is not fee not enabled, success",
func() {
suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)
ack = channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement()
ack = ibcmock.MockAcknowledgement.Acknowledgement()

expectedBalance = originalBalance
},
Expand All @@ -590,7 +590,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress()

ack = types.IncentivizedAcknowledgement{
Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(),
Result: ibcmock.MockAcknowledgement.Acknowledgement(),
ForwardRelayerAddress: blockedAddr.String(),
}.Acknowledgement()

Expand All @@ -604,24 +604,20 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {
tc := tc
suite.Run(tc.name, func() {
suite.SetupTest()
expectedRelayerBalance = sdk.Coins{} // reset

// open incentivized channel
suite.coordinator.Setup(suite.path)
packet := suite.CreateMockPacket()

// set up coin & ics20 packet
coin := ibctesting.TestCoin
packet := suite.CreateICS20Packet(coin)
expectedRelayerBalance = sdk.Coins{} // reset

// set up module and callbacks
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort)
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort)
suite.Require().NoError(err)

cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

// escrow the packet fee
packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence())
packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence())
identifiedFee = types.NewIdentifiedPacketFee(
packetId,
types.Fee{
Expand All @@ -639,7 +635,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() {

// must be changed explicitly
ack = types.IncentivizedAcknowledgement{
Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(),
Result: ibcmock.MockAcknowledgement.Acknowledgement(),
ForwardRelayerAddress: relayerAddr.String(),
}.Acknowledgement()

Expand Down

0 comments on commit ad7827f

Please sign in to comment.