Skip to content

Commit

Permalink
DistributePacketFeesOnTimeout not return error
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed May 15, 2022
1 parent a11869b commit e4adbd9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
4 changes: 1 addition & 3 deletions modules/apps/29-fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/escrow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions modules/apps/29-fee/keeper/escrow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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() {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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,
},
}

Expand Down Expand Up @@ -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()
})
Expand Down

0 comments on commit e4adbd9

Please sign in to comment.