diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 1c5609665bc..5513afa7384 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -301,14 +301,14 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { { "success", func(suite *FeeTestSuite) { - packetId := channeltypes.NewPacketId( + packetID := channeltypes.NewPacketId( suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1, ) refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) }, false, @@ -323,7 +323,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { } refundAcc := suite.chainA.SenderAccount.GetAddress() identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetId, identifiedFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) @@ -379,14 +379,14 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { { "success", func(suite *FeeTestSuite) { - packetId := channeltypes.PacketId{ + packetID := channeltypes.PacketId{ PortId: suite.path.EndpointA.ChannelConfig.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) }, false, @@ -394,14 +394,14 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { { "module account balance insufficient", func(suite *FeeTestSuite) { - packetId := channeltypes.PacketId{ + packetID := channeltypes.PacketId{ PortId: suite.path.EndpointA.ChannelConfig.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) @@ -553,8 +553,8 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { { "no op success without a packet fee", func() { - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetID) ack = types.IncentivizedAcknowledgement{ Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), @@ -621,9 +621,9 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { 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(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) identifiedFee = types.NewIdentifiedPacketFee( - packetId, + packetID, types.Fee{ RecvFee: validCoins, AckFee: validCoins2, @@ -632,7 +632,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { suite.chainA.SenderAccount.GetAddress().String(), []string{}, ) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) relayerAddr := suite.chainB.SenderAccount.GetAddress() @@ -706,8 +706,8 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { "no op if identified packet fee doesn't exist", func() { // delete packet fee - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetID) expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, @@ -750,13 +750,13 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) // must be explicitly changed relayerAddr = suite.chainB.SenderAccount.GetAddress() identifiedFee = types.NewIdentifiedPacketFee( - packetId, + packetID, types.Fee{ RecvFee: validCoins, AckFee: validCoins2, @@ -766,7 +766,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { []string{}, ) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) // log original sender balance @@ -793,7 +793,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { relayerBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), relayerAddr, ibctesting.TestCoin.Denom)) if tc.expFeeDistributed { // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetId) + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetID) suite.Require().False(found) suite.Require().Equal(identifiedFee.Fee.TimeoutFee, relayerBalance) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index dcb2bdbfbd3..e0524752131 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -16,7 +16,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { ackFee sdk.Coins receiveFee sdk.Coins timeoutFee sdk.Coins - packetId channeltypes.PacketId + packetID channeltypes.PacketId ) testCases := []struct { @@ -35,18 +35,18 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) feesInEscrow := types.IdentifiedPacketFees{ PacketFees: []types.IdentifiedPacketFee{identifiedPacketFee}, } - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetId, feesInEscrow) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetID, feesInEscrow) }, true, }, { "fee not enabled on this channel", func() { - packetId.ChannelId = "disabled_channel" + packetID.ChannelId = "disabled_channel" }, false, }, { @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { receiveFee = defaultReceiveFee ackFee = defaultAckFee timeoutFee = defaultTimeoutFee - packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(1)) + packetID = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(1)) tc.malleate() fee := types.Fee{ @@ -92,16 +92,16 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { AckFee: ackFee, TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) // refundAcc balance before escrow originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) // escrow the packet fee - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) if tc.expPass { - feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetId) + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetID) suite.Require().True(found) // check if the escrowed fee is set in state suite.Require().True(feesInEscrow.PacketFees[0].Fee.AckFee.IsEqual(fee.AckFee)) @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, validSeq) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, validSeq) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -166,12 +166,12 @@ func (suite *KeeperTestSuite) TestDistributeFee() { } // escrow the packet fee & store the fee in state - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // escrow a second packet fee to test with multiple fees distributed - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) tc.malleate() @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { if tc.expPass { // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetID) suite.Require().False(found) // check if the reverse relayer is paid @@ -221,7 +221,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { refundAcc := suite.chainA.SenderAccount.GetAddress() timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - packetId := channeltypes.NewPacketId( + packetID := channeltypes.NewPacketId( suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1, @@ -235,16 +235,16 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { // escrow the packet fee & store the fee in state identifiedPacketFee := types.NewIdentifiedPacketFee( - packetId, + packetID, fee, refundAcc.String(), []string{}, ) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // escrow a second packet fee to test with multiple fees distributed - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // refundAcc balance after escrow @@ -286,21 +286,21 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetId, identifiedPacketFee) suite.Require().NoError(err) } // send a packet over a different channel to ensure this fee is not refunded - packetId := channeltypes.NewPacketId("channel-1", ibctesting.MockFeePort, 1) + packetID := channeltypes.NewPacketId("channel-1", ibctesting.MockFeePort, 1) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, "channel-1") - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // check that refunding all fees on channel-0 refunds all fees except for fee on channel-1 @@ -312,10 +312,10 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { suite.Require().Equal(prevBal, afterBal.Add(fee.RecvFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") // create escrow and then change module account balance to cause error on refund - packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(6)) + packetID = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(6)) - identifiedPacketFee = types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + identifiedPacketFee = types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, fee.TimeoutFee)