-
Notifications
You must be signed in to change notification settings - Fork 579
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
(tests): e2e test for failed forwarding #6876
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fec02f8
Create e2e test for failed forwarding.
bznein dfee138
Added comment.
bznein e9048cb
Fixed string
bznein 649402c
Appeasing the linter
bznein 25cd1d2
Missed renaming
bznein ebbc909
Fix
bznein 1c2166b
Change denom.
bznein 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 |
---|---|---|
|
@@ -289,3 +289,78 @@ func (s *TransferForwardingTestSuite) TestChannelUpgradeForwarding_Succeeds() { | |
s.Require().Equal(expected, actualBalance.Int64()) | ||
}) | ||
} | ||
|
||
// TestFailedForwarding tests the scenario in which the packet is sent from | ||
// A to C (through B) but it can't reach C (we use an invalid address). | ||
func (s *TransferForwardingTestSuite) TestFailedForwarding() { | ||
t := s.T() | ||
ctx := context.TODO() | ||
|
||
testName := t.Name() | ||
t.Parallel() | ||
relayer := s.CreateDefaultPaths(testName) | ||
chains := s.GetAllChains() | ||
|
||
chainA, chainB, chainC := chains[0], chains[1], chains[2] | ||
|
||
chainADenom := chainA.Config().Denom | ||
|
||
chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||
chainAAddress := chainAWallet.FormattedAddress() | ||
|
||
chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) | ||
|
||
chainCWallet := s.CreateUserOnChainC(ctx, testvalues.StartingTokenAmount) | ||
|
||
channelAtoB := s.GetChainAChannelForTest(testName) | ||
channelBtoC := s.GetChannelsForTest(chainB, testName)[1] | ||
|
||
s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") | ||
|
||
chainBstartingBalance, err := testsuite.GetChainBalanceForDenom(ctx, chainB, chainADenom, chainBWallet) | ||
s.Require().NoError(err) | ||
|
||
chainCstartingBalance, err := testsuite.GetChainBalanceForDenom(ctx, chainC, chainADenom, chainCWallet) | ||
s.Require().NoError(err) | ||
|
||
t.Run("native IBC token transfer from chainA to invalid address through B", func(t *testing.T) { | ||
inFiveMinutes := time.Now().Add(5 * time.Minute).UnixNano() | ||
forwarding := transfertypes.NewForwarding(false, transfertypes.NewHop(channelBtoC.PortID, channelBtoC.ChannelID)) | ||
resp := s.Transfer(ctx, chainA, chainAWallet, channelAtoB.PortID, channelAtoB.ChannelID, testvalues.DefaultTransferCoins(chainADenom), chainAAddress, testvalues.InvalidAddress, clienttypes.ZeroHeight(), uint64(inFiveMinutes), "", forwarding) | ||
s.AssertTxSuccess(resp) | ||
}) | ||
|
||
t.Run("tokens are escrowed", func(t *testing.T) { | ||
actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) | ||
s.Require().NoError(err) | ||
|
||
expected := testvalues.StartingTokenAmount - testvalues.IBCTransferAmount | ||
s.Require().Equal(expected, actualBalance) | ||
}) | ||
|
||
t.Run("start relayer", func(t *testing.T) { | ||
s.StartRelayer(relayer, testName) | ||
}) | ||
|
||
t.Run("packets are relayed", func(t *testing.T) { | ||
s.AssertPacketRelayed(ctx, chainA, channelAtoB.PortID, channelAtoB.ChannelID, 1) | ||
}) | ||
|
||
t.Run("token transfer amount unescrowed", func(t *testing.T) { | ||
actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) | ||
s.Require().NoError(err) | ||
|
||
expected := testvalues.StartingTokenAmount | ||
s.Require().Equal(expected, actualBalance) | ||
}) | ||
|
||
t.Run("balances for B and C have not changed", func(t *testing.T) { | ||
chainBBalance, err := testsuite.GetChainBalanceForDenom(ctx, chainB, chainADenom, chainBWallet) | ||
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.
|
||
s.Require().NoError(err) | ||
s.Require().Equal(chainBstartingBalance, chainBBalance) | ||
|
||
chainCBalance, err := testsuite.GetChainBalanceForDenom(ctx, chainC, chainADenom, chainCWallet) | ||
s.Require().NoError(err) | ||
s.Require().Equal(chainCstartingBalance, chainCBalance) | ||
}) | ||
} |
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
Oops, something went wrong.
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.
Usage of
chainADenom
here and for the balance on chain C is not correct, right? We should be using the IBC denom con chain B and C respectively, right?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.
you're absolutely right, I'll fix this, thanks for catching it!