-
Notifications
You must be signed in to change notification settings - Fork 624
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
refactor: ics29 use mock module for OnTimeoutPacket testing #928
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ import ( | |
host "github.com/cosmos/ibc-go/v3/modules/core/24-host" | ||
ibctesting "github.com/cosmos/ibc-go/v3/testing" | ||
ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" | ||
"github.com/cosmos/ibc-go/v3/testing/simapp" | ||
) | ||
|
||
var ( | ||
|
@@ -694,7 +693,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { | |
func() { | ||
suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) | ||
|
||
expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer | ||
expectedBalance = originalBalance | ||
}, | ||
false, | ||
}, | ||
|
@@ -705,7 +704,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { | |
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 | ||
expectedBalance = originalBalance | ||
}, | ||
false, | ||
}, | ||
|
@@ -716,8 +715,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { | |
|
||
expectedBalance = originalBalance. | ||
Add(identifiedFee.Fee.RecvFee[0]). | ||
Add(identifiedFee.Fee.AckFee[0]). | ||
Add(ibctesting.TestCoin) // timeout refund for ics20 transfer | ||
Add(identifiedFee.Fee.AckFee[0]) | ||
}, | ||
false, | ||
}, | ||
|
@@ -726,27 +724,18 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { | |
for _, tc := range testCases { | ||
tc := tc | ||
suite.Run(tc.name, func() { | ||
suite.SetupTest() | ||
|
||
// open incentivized channel | ||
suite.SetupMockTest() | ||
suite.coordinator.Setup(suite.path) | ||
|
||
// set up coin & create ics20 packet | ||
coin := ibctesting.TestCoin | ||
packet := suite.CreateICS20Packet(coin) | ||
|
||
// setup for ics20: fund chain A's escrow path so that tokens can be unescrowed upon timeout | ||
escrow := transfertypes.GetEscrowAddress(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) | ||
suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) | ||
Comment on lines
-738
to
-740
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. no longer needed. It was only there so the transfer OnTimeoutPacket callback wouldn't error |
||
packet := suite.CreateMockPacket() | ||
|
||
// 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) | ||
|
||
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()) | ||
|
||
// must be explicitly changed | ||
relayerAddr = suite.chainB.SenderAccount.GetAddress() | ||
|
@@ -772,8 +761,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { | |
// default to success case | ||
expectedBalance = originalBalance. | ||
Add(identifiedFee.Fee.RecvFee[0]). | ||
Add(identifiedFee.Fee.AckFee[0]). | ||
Add(coin) // timeout refund from ics20 transfer | ||
Add(identifiedFee.Fee.AckFee[0]) | ||
Comment on lines
-775
to
+764
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. ditto |
||
|
||
// malleate test case | ||
tc.malleate() | ||
|
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.
I don't understand how this was passing before. Seems like you're actually changing the test logic rather than just a refactor?