From 8f533e445ea5093691cdf002cbf6868145fbcaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 11 Aug 2022 11:14:03 +0200 Subject: [PATCH 1/2] add timeout height helper function to default e2e testsuite --- e2e/testsuite/testsuite.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 80a5ea42ed4..10d58ef735a 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/ibc-go/e2e/testconfig" feetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types" + clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types" ) const ( @@ -313,6 +314,14 @@ func (s *E2ETestSuite) getRelayerExecReporter() *testreporter.RelayerExecReporte return rep.RelayerExecReporter(s.T()) } +// GetTimeoutHeight returns a timeout height of 1000 blocks above the current block height. +// This function should be used when the timeout is never expected to be reached +func (s *E2ETestSuite) GetTimeoutHeight(ctx context.Context, chain *cosmos.CosmosChain) clienttypes.Height { + height, err := chain.Height(ctx) + s.Require().NoError(err) + return clienttypes.NewHeight(clienttypes.ParseChainID(chain.Config().ChainID), uint64(height)+1000) +} + // GetNativeChainBalance returns the balance of a specific user on a chain using the native denom. func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibctest.User) (int64, error) { bal, err := chain.GetBalance(ctx, user.Bech32Address(chain.Config().Bech32Prefix), chain.Config().Denom) From bcf67532064291110d2a36cc3ece264fcdffe8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 11 Aug 2022 11:30:02 +0200 Subject: [PATCH 2/2] replace hardcoded timeout with function call --- e2e/fee_middleware_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/fee_middleware_test.go b/e2e/fee_middleware_test.go index 3906b88bbc8..b9fc379f17a 100644 --- a/e2e/fee_middleware_test.go +++ b/e2e/fee_middleware_test.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/ibc-go/e2e/testvalues" feetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v5/modules/core/04-channel/types" ) @@ -253,7 +252,7 @@ func (s *FeeMiddlewareTestSuite) TestMultiMsg_MsgPayPacketFeeSingleSender() { }) payPacketFeeMsg := feetypes.NewMsgPayPacketFee(testFee, channelA.PortID, channelA.ChannelID, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), nil) - transferMsg := transfertypes.NewMsgTransfer(channelA.PortID, channelA.ChannelID, transferAmount, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), chainBWallet.Bech32Address(chainB.Config().Bech32Prefix), clienttypes.NewHeight(1, 1000), 0) + transferMsg := transfertypes.NewMsgTransfer(channelA.PortID, channelA.ChannelID, transferAmount, chainAWallet.Bech32Address(chainA.Config().Bech32Prefix), chainBWallet.Bech32Address(chainB.Config().Bech32Prefix), s.GetTimeoutHeight(ctx, chainB), 0) resp, err := s.BroadcastMessages(ctx, chainA, chainAWallet, payPacketFeeMsg, transferMsg) t.Run("transfer successful", func(t *testing.T) {