From e4adbd9f835cd7156a8dc76925607ba17061a60e Mon Sep 17 00:00:00 2001 From: vuong Date: Sun, 15 May 2022 16:15:14 +0700 Subject: [PATCH] DistributePacketFeesOnTimeout not return error --- modules/apps/29-fee/ibc_middleware.go | 4 +--- modules/apps/29-fee/keeper/escrow.go | 2 +- modules/apps/29-fee/keeper/escrow_test.go | 14 ++++---------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/modules/apps/29-fee/ibc_middleware.go b/modules/apps/29-fee/ibc_middleware.go index 9914d8bc481..dde334f533c 100644 --- a/modules/apps/29-fee/ibc_middleware.go +++ b/modules/apps/29-fee/ibc_middleware.go @@ -258,9 +258,7 @@ func (im IBCMiddleware) OnTimeoutPacket( packetID := channeltypes.NewPacketId(packet.SourcePort, packet.SourceChannel, packet.Sequence) feesInEscrow, found := im.keeper.GetFeesInEscrow(ctx, packetID) if found { - if err := im.keeper.DistributePacketFeesOnTimeout(ctx, relayer, feesInEscrow.PacketFees, packetID); err != nil { - return err - } + im.keeper.DistributePacketFeesOnTimeout(ctx, relayer, feesInEscrow.PacketFees, packetID) } // call underlying callback diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 77be53a8db0..e609c734f5e 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -120,7 +120,7 @@ func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, timeoutRelayer sd // locking the fee module are persisted k.lockFeeModule(ctx) - return types.ErrFeeModuleLocked + return nil } // check if refundAcc address works diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index ff322b13445..4ac6e2ed03f 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -173,10 +173,9 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { ) testCases := []struct { - name string - malleate func() - expResult func() - distributePacketError error + name string + malleate func() + expResult func() }{ { "success", @@ -196,7 +195,6 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { balance = suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.DefaultBondDenom) suite.Require().Equal(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), balance) }, - nil, }, { "escrow account out of balance, fee module becomes locked - no distribution", func() { @@ -214,7 +212,6 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { balance := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress()) suite.Require().Equal(expectedModuleAccBal, balance) }, - types.ErrFeeModuleLocked, }, { "invalid timeout relayer address: timeout fee returned to sender", @@ -227,7 +224,6 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { balance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) suite.Require().Equal(expectedRefundAccBal, balance) }, - nil, }, { "invalid refund address: no-op, recv and ack fees remain in escrow", @@ -241,7 +237,6 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { balance := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.DefaultBondDenom) suite.Require().Equal(expectedModuleAccBal, balance) }, - nil, }, } @@ -273,8 +268,7 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { timeoutRelayerBal = suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), timeoutRelayer, sdk.DefaultBondDenom) refundAccBal = suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - distributePacketError := suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), timeoutRelayer, packetFees, packetID) - suite.Require().Equal(tc.distributePacketError, distributePacketError) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), timeoutRelayer, packetFees, packetID) tc.expResult() })