-
Notifications
You must be signed in to change notification settings - Fork 610
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
test: e2e test for timeout of ics20 packet #1992
Changes from all commits
eafa496
d7d515a
2c37cab
38b0ac0
07dc49b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |||||
"context" | ||||||
"fmt" | ||||||
"testing" | ||||||
"time" | ||||||
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types" | ||||||
"github.com/strangelove-ventures/ibctest" | ||||||
|
@@ -161,6 +162,53 @@ func (s *TransferTestSuite) TestMsgTransfer_Fails_InvalidAddress() { | |||||
}) | ||||||
} | ||||||
|
||||||
func (s *TransferTestSuite) TestMsgTransfer_Timeout_Nonincentivized() { | ||||||
t := s.T() | ||||||
ctx := context.TODO() | ||||||
|
||||||
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) | ||||||
chainA, chainB := s.GetChains() | ||||||
chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||||||
chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) | ||||||
|
||||||
chainBWalletAmount := ibc.WalletAmount{ | ||||||
Address: chainBWallet.Bech32Address(chainB.Config().Bech32Prefix), // destination address | ||||||
Denom: chainA.Config().Denom, | ||||||
Amount: testvalues.IBCTransferAmount, | ||||||
} | ||||||
|
||||||
t.Run("IBC transfer packet timesout", func(t *testing.T) { | ||||||
tx, err := chainA.SendIBCTransfer(ctx, channelA.ChannelID, chainAWallet.KeyName, chainBWalletAmount, testvalues.ImmediatelyTimeout()) | ||||||
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. @colin-axner I tried to use your helper function for broadcasting the message instead of using the built-in library fn but for some reason the packet never timesout. Everything works as expected when using the built in transfer helper. Not sure if this is a golang relayer issue or if the message doesn't get broadcast correctly. 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. should we create an issue to investigate this? 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. Agreed, I'd like to understand why this is the case? 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. The issue is that the cli takes in a relative timeout. So the in this instance, 1 is being passed for the timeout timestamp which is added to the latest known consensus state timestamp (which passes for sending a packet). In the function I added, you have to pass the absolute timeout |
||||||
s.Require().NoError(err) | ||||||
s.Require().NoError(tx.Validate(), "source ibc transfer tx is invalid") | ||||||
time.Sleep(time.Nanosecond * 1) // want it to timeout immediately | ||||||
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. same difference I think
Suggested change
|
||||||
}) | ||||||
|
||||||
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) | ||||||
}) | ||||||
|
||||||
t.Run("ensure escrowed tokens have been refunded to sender due to timeout", func(t *testing.T) { | ||||||
// ensure destination address did not recieve any tokens | ||||||
bal, err := s.GetChainBNativeBalance(ctx, chainBWallet) | ||||||
s.Require().NoError(err) | ||||||
s.Require().Equal(testvalues.StartingTokenAmount, bal) | ||||||
|
||||||
// ensure that the sender address has been successfully refunded the full amount | ||||||
bal, err = s.GetChainANativeBalance(ctx, chainAWallet) | ||||||
s.Require().NoError(err) | ||||||
s.Require().Equal(testvalues.StartingTokenAmount, bal) | ||||||
}) | ||||||
} | ||||||
|
||||||
// transferChannelOptions configures both of the chains to have non-incentivized transfer channels. | ||||||
func transferChannelOptions() func(options *ibc.CreateChannelOptions) { | ||||||
return func(opts *ibc.CreateChannelOptions) { | ||||||
|
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.
nit: should we make "IBC transfer packet timeout" or "IBC transfer packet times out"