-
Notifications
You must be signed in to change notification settings - Fork 749
E2E: Fee middleware counterparty payee not set #1746
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
Changes from 17 commits
ff9fdc7
f72545d
3841260
e1793b9
6be8aa9
44bdab1
20ad572
3383e27
dce23ba
e08565c
fa7685f
c9a66d3
c8e50fe
2abfc64
0d08c7d
767f62f
1a5c994
bf97dcd
dc5bc83
2b156f9
1ffb7a8
54c4114
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 |
|---|---|---|
|
|
@@ -426,6 +426,108 @@ func (s *FeeMiddlewareTestSuite) TestMsgPayPacketFee_SingleSender_TimesOut() { | |
| }) | ||
| } | ||
|
|
||
| func (s *FeeMiddlewareTestSuite) TestPayPacketFeeAsync_SingleSender_NoCounterPartyAddress() { | ||
| t := s.T() | ||
| ctx := context.TODO() | ||
|
|
||
| relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions()) | ||
| chainA, chainB := s.GetChains() | ||
|
|
||
| var ( | ||
| chainADenom = chainA.Config().Denom | ||
| testFee = testvalues.DefaultFee(chainADenom) | ||
| chainATx ibc.Tx | ||
| payPacketFeeTxResp sdk.TxResponse | ||
| ) | ||
|
|
||
| chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||
|
|
||
| t.Run("relayer wallets recovered", func(t *testing.T) { | ||
| err := s.RecoverRelayerWallets(ctx, relayer) | ||
| s.Require().NoError(err) | ||
| }) | ||
|
|
||
| chainBWalletAmount := ibc.WalletAmount{ | ||
| Address: chainAWallet.Bech32Address(chainB.Config().Bech32Prefix), // destination address | ||
| Denom: chainADenom, | ||
| Amount: testvalues.IBCTransferAmount, | ||
| } | ||
|
|
||
| t.Run("send IBC transfer", func(t *testing.T) { | ||
| var err error | ||
| chainATx, err = chainA.SendIBCTransfer(ctx, channelA.ChannelID, chainAWallet.KeyName, chainBWalletAmount, nil) | ||
| s.Require().NoError(err) | ||
| s.Require().NoError(chainATx.Validate(), "source ibc transfer tx is invalid") | ||
| }) | ||
|
|
||
| t.Run("tokens are escrowed", func(t *testing.T) { | ||
| actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) | ||
| s.Require().NoError(err) | ||
|
|
||
| expected := testvalues.StartingTokenAmount - chainBWalletAmount.Amount | ||
| s.Require().Equal(expected, actualBalance) | ||
| }) | ||
|
|
||
| t.Run("pay packet fee", func(t *testing.T) { | ||
| t.Run("no incentivized packets", func(t *testing.T) { | ||
| packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) | ||
| s.Require().NoError(err) | ||
| s.Require().Empty(packets) | ||
| }) | ||
|
|
||
| packetId := channeltypes.NewPacketId(channelA.PortID, channelA.ChannelID, 1) | ||
| packetFee := feetypes.NewPacketFee(testFee, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), nil) | ||
|
|
||
| t.Run("should succeed", func(t *testing.T) { | ||
|
Contributor
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. Maybe something extra in the description to make it more explicit? Like
Contributor
Author
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. based on the nesting, the resulting message will look like |
||
| var err error | ||
| payPacketFeeTxResp, err = s.PayPacketFeeAsync(ctx, chainA, chainAWallet, packetId, packetFee) | ||
| s.Require().NoError(err) | ||
| s.AssertValidTxResponse(payPacketFeeTxResp) | ||
|
Contributor
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. love this helper function ❤️ |
||
| }) | ||
|
|
||
| t.Run("should be incentivized packets", func(t *testing.T) { | ||
| packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) | ||
| s.Require().NoError(err) | ||
| s.Require().Len(packets, 1) | ||
| actualFee := packets[0].PacketFees[0].Fee | ||
|
|
||
| s.Require().True(actualFee.RecvFee.IsEqual(testFee.RecvFee)) | ||
| s.Require().True(actualFee.AckFee.IsEqual(testFee.AckFee)) | ||
| s.Require().True(actualFee.TimeoutFee.IsEqual(testFee.TimeoutFee)) | ||
| }) | ||
| }) | ||
|
|
||
| t.Run("balance should be lowered by sum of recv, ack and timeout", func(t *testing.T) { | ||
| // The balance should be lowered by the sum of the recv, ack and timeout fees. | ||
| actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) | ||
| s.Require().NoError(err) | ||
|
|
||
| expected := testvalues.StartingTokenAmount - chainBWalletAmount.Amount - testFee.Total().AmountOf(chainADenom).Int64() | ||
| s.Require().Equal(expected, actualBalance) | ||
| }) | ||
|
|
||
| t.Run("start relayer", func(t *testing.T) { | ||
| s.StartRelayer(relayer) | ||
| }) | ||
|
|
||
| t.Run("with no counter party address", func(t *testing.T) { | ||
| t.Run("packets are relayed", func(t *testing.T) { | ||
| packets, err := s.QueryIncentivizedPacketsForChannel(ctx, chainA, channelA.PortID, channelA.ChannelID) | ||
| s.Require().NoError(err) | ||
| s.Require().Empty(packets) | ||
| }) | ||
|
|
||
| t.Run("timeout and recv fee are refunded", func(t *testing.T) { | ||
| actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) | ||
| s.Require().NoError(err) | ||
|
|
||
| // once the relayer has relayed the packets, the timeout and recv fee should be refunded. | ||
| expected := testvalues.StartingTokenAmount - chainBWalletAmount.Amount - testFee.AckFee.AmountOf(chainADenom).Int64() | ||
| s.Require().Equal(expected, actualBalance) | ||
| }) | ||
| }) | ||
| } | ||
|
|
||
| // feeMiddlewareChannelOptions configures both of the chains to have fee middleware enabled. | ||
| func feeMiddlewareChannelOptions() 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.
I think at least modifying the sequence to use the returned chainATx.Packet.GetSequence makes sense, I have no preference on the other arguments, I just figure this code will be copied a lot so might make more sense to derive the values
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.
ah definitely, good catch.