-
Notifications
You must be signed in to change notification settings - Fork 758
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
Merged
chatton
merged 22 commits into
main
from
cian/issue#1686-fee-middleware-counterparty-payee-not-set
Aug 10, 2022
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ff9fdc7
test: adding TestAsyncSingleSenderNoCounterPartyAddress
chatton f72545d
test: adding TestPayPacketFeeAsyncSingleSenderNoCounterPartyAddress
chatton 3841260
test: correcting refund address
chatton e1793b9
test: adding sleep after packet incentivization
chatton 6be8aa9
test: registering counter party payee
chatton 44bdab1
removing additional using on chainb
chatton 20ad572
test: fixing packet ID
chatton 3383e27
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton dce23ba
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton e08565c
chore: removing all gas fees
chatton fa7685f
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton c9a66d3
chore: merge main
chatton c8e50fe
chore: merge main
chatton 2abfc64
chore: removing wait for blocks
chatton 0d08c7d
Update e2e/fee_middleware_test.go
chatton 767f62f
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton 1a5c994
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton bf97dcd
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton dc5bc83
chore: addressing PR feedback
chatton 2b156f9
chore: merge main
chatton 1ffb7a8
chore: reference sequence directly instead of hard coded value
chatton 54c4114
Merge branch 'main' into cian/issue#1686-fee-middleware-counterparty-…
chatton 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 hidden or 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 |
|---|---|---|
|
|
@@ -30,8 +30,7 @@ type FeeMiddlewareTestSuite struct { | |
|
|
||
| // RegisterCounterPartyPayee broadcasts a MsgRegisterCounterpartyPayee message. | ||
| func (s *FeeMiddlewareTestSuite) RegisterCounterPartyPayee(ctx context.Context, chain *cosmos.CosmosChain, | ||
| user *ibctest.User, portID, channelID, relayerAddr, counterpartyPayeeAddr string, | ||
| ) (sdk.TxResponse, error) { | ||
| user *ibctest.User, portID, channelID, relayerAddr, counterpartyPayeeAddr string) (sdk.TxResponse, error) { | ||
| msg := feetypes.NewMsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr) | ||
| return s.BroadcastMessages(ctx, chain, user, msg) | ||
| } | ||
|
|
@@ -148,7 +147,7 @@ func (s *FeeMiddlewareTestSuite) TestMsgPayPacketFee_AsyncSingleSender_Succeeds( | |
| s.Require().Empty(packets) | ||
| }) | ||
|
|
||
| packetId := channeltypes.NewPacketID(channelA.PortID, channelA.ChannelID, 1) | ||
| packetId := channeltypes.NewPacketID(channelA.PortID, channelA.ChannelID, chainATx.Packet.Sequence) | ||
| packetFee := feetypes.NewPacketFee(testFee, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), nil) | ||
|
|
||
| t.Run("should succeed", func(t *testing.T) { | ||
|
|
@@ -371,7 +370,7 @@ func (s *FeeMiddlewareTestSuite) TestMsgPayPacketFee_SingleSender_TimesOut() { | |
| }) | ||
|
|
||
| t.Run("pay packet fee", func(t *testing.T) { | ||
| packetId := channeltypes.NewPacketID(channelA.PortID, channelA.ChannelID, 1) | ||
| packetId := channeltypes.NewPacketID(channelA.PortID, channelA.ChannelID, chainATx.Packet.Sequence) | ||
| packetFee := feetypes.NewPacketFee(testFee, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), nil) | ||
|
|
||
| t.Run("no incentivized packets", func(t *testing.T) { | ||
|
|
@@ -426,6 +425,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, chainATx.Packet.Sequence) | ||
| packetFee := feetypes.NewPacketFee(testFee, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), nil) | ||
|
|
||
| t.Run("should succeed", func(t *testing.T) { | ||
| 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) { | ||
|
|
||
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.
Maybe something extra in the description to make it more explicit? Like
pay packet fee should succeed?Uh oh!
There was an error while loading. Please reload this page.
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.
based on the nesting, the resulting message will look like
TestPayPacketFeeAsync_SingleSender_NoCounterPartyAddress/pay_packet_fee/should_succeed