-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip distribution if refund fails to send on channel closure #1523
Merged
chatton
merged 12 commits into
main
from
cian/issue#1396-skip-distribution-if-refund-fails-to-send-on-channel-closure
Jun 13, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
971c40a
fix: don't close channel on faulty refund address
chatton 85aba61
test: Added test for invalid refund address
chatton 33606ee
test: updated existing test for blocked address
chatton 7453287
Merge branch 'main' into cian/issue#1396-skip-distribution-if-refund-…
chatton a640f3c
chore: Adding changelog entry.
chatton 7ba892d
chore: Adding changelog entry.
chatton 59a42df
Merge remote-tracking branch 'origin/cian/issue#1396-skip-distributio…
chatton ea6033f
fix: invalid address now also does not block channel closure.
chatton 27daca3
Merge branch 'main' into cian/issue#1396-skip-distribution-if-refund-…
chatton c37dffc
test: update existing test to succeed as an error is no longer returned
chatton cf024b7
Merge remote-tracking branch 'origin/cian/issue#1396-skip-distributio…
chatton 5774011
test: update existing test to succeed as an error is no longer returned
chatton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,10 @@ package keeper_test | |
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/tendermint/tendermint/crypto/secp256k1" | ||
|
||
"github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" | ||
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" | ||
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" | ||
"github.com/tendermint/tendermint/crypto/secp256k1" | ||
Comment on lines
-5
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: group imports by type, see #382 import (
// standard library imports
"fmt"
"testing"
// external library imports
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
// ibc-go library imports
"github.com/cosmos/ibc-go/modules/core/23-commitment/types"
) |
||
) | ||
|
||
func (suite *KeeperTestSuite) TestDistributeFee() { | ||
|
@@ -277,12 +276,13 @@ func (suite *KeeperTestSuite) TestDistributePacketFeesOnTimeout() { | |
|
||
func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() { | ||
var ( | ||
expIdentifiedPacketFees []types.IdentifiedPacketFees | ||
expEscrowBal sdk.Coins | ||
expRefundBal sdk.Coins | ||
refundAcc sdk.AccAddress | ||
fee types.Fee | ||
locked bool | ||
expIdentifiedPacketFees []types.IdentifiedPacketFees | ||
expEscrowBal sdk.Coins | ||
expRefundBal sdk.Coins | ||
refundAcc sdk.AccAddress | ||
fee types.Fee | ||
locked bool | ||
expectEscrowFeesToBeDeleted bool | ||
) | ||
|
||
testCases := []struct { | ||
|
@@ -375,6 +375,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() { | |
{ | ||
"invalid refund acc address", func() { | ||
// store the fee in state & update escrow account balance | ||
expectEscrowFeesToBeDeleted = false | ||
packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, uint64(1)) | ||
packetFees := types.NewPacketFees([]types.PacketFee{types.NewPacketFee(fee, "invalid refund address", nil)}) | ||
identifiedPacketFees := types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees) | ||
|
@@ -385,10 +386,14 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() { | |
suite.Require().NoError(err) | ||
|
||
expIdentifiedPacketFees = []types.IdentifiedPacketFees{identifiedPacketFees} | ||
}, false, | ||
|
||
expEscrowBal = fee.Total() | ||
expRefundBal = expRefundBal.Sub(fee.Total()) | ||
}, true, | ||
}, | ||
{ | ||
"distributing to blocked address is skipped", func() { | ||
expectEscrowFeesToBeDeleted = false | ||
blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress().String() | ||
|
||
// store the fee in state & update escrow account balance | ||
|
@@ -418,6 +423,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() { | |
expIdentifiedPacketFees = []types.IdentifiedPacketFees{} | ||
expEscrowBal = sdk.Coins{} | ||
locked = false | ||
expectEscrowFeesToBeDeleted = true | ||
|
||
// setup | ||
refundAcc = suite.chainA.SenderAccount.GetAddress() | ||
|
@@ -464,8 +470,8 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannelClosure() { | |
suite.Require().Equal(expEscrowBal, escrowBal) // escrow balance should be empty | ||
suite.Require().Equal(expRefundBal, refundBal) // all packets should have been refunded | ||
|
||
// all fees in escrow should be deleted for this channel | ||
suite.Require().Empty(suite.chainA.GetSimApp().IBCFeeKeeper.GetIdentifiedPacketFeesForChannel(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) | ||
// all fees in escrow should be deleted if expected for this channel | ||
suite.Require().Equal(expectEscrowFeesToBeDeleted, len(suite.chainA.GetSimApp().IBCFeeKeeper.GetIdentifiedPacketFeesForChannel(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) == 0) | ||
} | ||
}) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's possible an error occurred sending the coins, we don't want to remove them unless they were actually sent.