-
Notifications
You must be signed in to change notification settings - Fork 628
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
e2e: transfer memo tests #2306
e2e: transfer memo tests #2306
Changes from 27 commits
a9f4f40
2254b3d
ca6b1d1
ed80695
7c925b9
1448633
71eae26
2480e13
f754572
2ed648f
c43e5ad
bbd1d91
9db4f98
40709af
415cc40
1497a4a
5faf1db
8eb9bc8
389bb8a
47df4c6
f14fe9f
c466942
4737852
4c2e228
40bdac4
a6587eb
915b68b
85d6f20
c939043
05fed7b
f22779b
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 |
---|---|---|
|
@@ -76,7 +76,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { | |
s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") | ||
|
||
t.Run("native IBC token transfer from chainA to chainB, sender is source of tokens", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "") | ||
s.Require().NoError(err) | ||
s.AssertValidTxResponse(transferTxResp) | ||
}) | ||
|
@@ -106,7 +106,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Succeeds_Nonincentivized() { | |
}) | ||
|
||
t.Run("non-native IBC token transfer from chainB to chainA, receiver is source of tokens", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBIBCToken.IBCDenom()), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBIBCToken.IBCDenom()), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "") | ||
s.Require().NoError(err) | ||
s.AssertValidTxResponse(transferTxResp) | ||
}) | ||
|
@@ -148,7 +148,7 @@ func (s *TransferTestSuite) TestMsgTransfer_Fails_InvalidAddress() { | |
s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") | ||
|
||
t.Run("native IBC token transfer from chainA to invalid address", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, testvalues.InvalidAddress, s.GetTimeoutHeight(ctx, chainB), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, testvalues.InvalidAddress, s.GetTimeoutHeight(ctx, chainB), 0, "") | ||
s.Require().NoError(err) | ||
s.AssertValidTxResponse(transferTxResp) | ||
}) | ||
|
@@ -249,7 +249,7 @@ func (s *TransferTestSuite) TestSendEnabledParam() { | |
}) | ||
|
||
t.Run("ensure packets can be sent", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "") | ||
s.Require().NoError(err) | ||
s.AssertValidTxResponse(transferTxResp) | ||
}) | ||
|
@@ -269,7 +269,7 @@ func (s *TransferTestSuite) TestSendEnabledParam() { | |
}) | ||
|
||
t.Run("ensure ics20 transfer fails", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "") | ||
s.Require().NoError(err) | ||
s.Require().Equal(transfertypes.ErrSendDisabled.ABCICode(), transferTxResp.Code) | ||
}) | ||
|
@@ -303,7 +303,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { | |
|
||
t.Run("ensure packets can be received, send from chainB to chainA", func(t *testing.T) { | ||
t.Run("send from chainB to chainA", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "") | ||
s.Require().NoError(err) | ||
s.AssertValidTxResponse(transferTxResp) | ||
}) | ||
|
@@ -351,7 +351,7 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { | |
|
||
t.Run("ensure ics20 transfer fails", func(t *testing.T) { | ||
t.Run("send from chainB to chainA", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0) | ||
transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "") | ||
s.Require().NoError(err) | ||
s.AssertValidTxResponse(transferTxResp) | ||
}) | ||
|
@@ -378,6 +378,90 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() { | |
}) | ||
} | ||
|
||
// memoFeatureReleases represents the releases the memo field was released in. | ||
var memoFeatureRelease = testsuite.FeatureReleases{ | ||
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. mega nit: should the var be the same as in the godoc or vice versa? |
||
MajorVersion: "v6", | ||
MinorVersions: []string{"v2.5, v3.4, v4.2, v5.1"}, | ||
} | ||
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. 👍 |
||
|
||
// This can be used to test sending with a transfer packet with a memo given different combinations of | ||
// ibc-go versions. | ||
// | ||
// TestMsgTransfer_WithMemo will test sending IBC transfers from chainA to chainB | ||
// If the chains contain a version of FungibleTokenPacketData with memo, both send and receive should succeed. | ||
// If one of the chains contains a version of FungibleTokenPacketData without memo, then receiving a packet with | ||
// memo should fail in that chain | ||
func (s *TransferTestSuite) TestMsgTransfer_WithMemo() { | ||
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. moved into |
||
t := s.T() | ||
ctx := context.TODO() | ||
|
||
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) | ||
chainA, chainB := s.GetChains() | ||
|
||
chainADenom := chainA.Config().Denom | ||
|
||
chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||
chainAAddress := chainAWallet.Bech32Address(chainA.Config().Bech32Prefix) | ||
|
||
chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) | ||
chainBAddress := chainBWallet.Bech32Address(chainB.Config().Bech32Prefix) | ||
|
||
s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") | ||
|
||
chainAVersion := chainA.Config().Images[0].Version | ||
chainBVersion := chainB.Config().Images[0].Version | ||
|
||
t.Logf("Running memo tests versions chainA: %s, chainB: %s", chainAVersion, chainBVersion) | ||
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 also remove? :D 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. sure! |
||
|
||
t.Run("IBC token transfer with memo from chainA to chainB", func(t *testing.T) { | ||
transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "memo") | ||
s.Require().NoError(err) | ||
|
||
if !memoFeatureRelease.IsSupported(chainAVersion) { | ||
s.Require().Equal(transferTxResp.Code, uint32(2)) | ||
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] we should have arguments in the order of 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. yup, nice catch |
||
s.Require().Contains(transferTxResp.RawLog, "errUnknownField") | ||
|
||
// transfer not sent, end test | ||
return | ||
} | ||
|
||
// sender chain supports feature | ||
s.AssertValidTxResponse(transferTxResp) | ||
|
||
}) | ||
|
||
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) | ||
}) | ||
|
||
chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) | ||
|
||
t.Run("packets relayed?", func(t *testing.T) { | ||
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] this punctuation is a bit strange in test names, is this intentional? 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. don't think so |
||
s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) | ||
|
||
actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom()) | ||
s.Require().NoError(err) | ||
|
||
if !memoFeatureRelease.IsSupported(chainBVersion) { | ||
s.Require().Equal(int64(0), actualBalance) | ||
|
||
// receive failed, end test | ||
return | ||
} | ||
|
||
// receving chain supports feature, transfer successful | ||
s.Require().Equal(testvalues.IBCTransferAmount, actualBalance) | ||
}) | ||
} | ||
|
||
// 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.
should we recomment this?
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.
we want this commented out as this comment is simply here for convenience to allow for testing against local ibc-go changes.
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.
ibc-go doesn't have a release with the memo changes yet so the constructors would break otherwise