Skip to content

Commit

Permalink
remove chanNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 committed Jan 24, 2024
1 parent 6c037b6 commit a9089d3
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions e2e/tests/core/04-channel/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ func (s *ChannelTestSuite) TestChannelUpgrade_WithFeeMiddleware_FailsWithTimeout
t := s.T()
ctx := context.TODO()

relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, s.TransferChannelOptions())
channelB := channelA.Counterparty
chainA, chainB := s.GetChains()
relayer, channelA := s.SetupRelayer(ctx, s.TransferChannelOptions(), chainA, chainB)
channelB := channelA.Counterparty

chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
Expand Down
24 changes: 10 additions & 14 deletions e2e/tests/interchain_accounts/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package interchainaccounts

import (
"context"
"strconv"
"testing"
"time"

Expand All @@ -27,17 +26,13 @@ import (
ibctesting "github.com/cosmos/ibc-go/v8/testing"
)


var chanNumber = 1

// orderMapping is a mapping from channel ordering to the string representation of the ordering.
// the representation can be different depending on the relayer implementation.
var orderMapping = map[channeltypes.Order][]string{
channeltypes.ORDERED: {channeltypes.ORDERED.String(), "Ordered"},
channeltypes.UNORDERED: {channeltypes.UNORDERED.String(), "Unordered"},
}


func TestInterchainAccountsTestSuite(t *testing.T) {
testifysuite.Run(t, new(InterchainAccountsTestSuite))
}
Expand Down Expand Up @@ -99,9 +94,9 @@ func (s *InterchainAccountsTestSuite) testMsgSendTxSuccessfulTransfer(order chan
s.Require().NotZero(len(hostAccount))

channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
chanNumber++

s.Require().NoError(err)
s.Require().Equal(len(channels), chanNumber)
s.Require().Equal(len(channels), 2)
icaChannel := channels[0]
s.Require().Contains(orderMapping[order], icaChannel.Ordering)
})
Expand Down Expand Up @@ -202,9 +197,9 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_FailedTransfer_InsufficientF
s.Require().NotZero(len(hostAccount))

channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
chanNumber++

s.Require().NoError(err)
s.Require().Equal(len(channels), chanNumber)
s.Require().Equal(len(channels), 2)
})

t.Run("fail to execute bank transfer over ICA", func(t *testing.T) {
Expand Down Expand Up @@ -279,6 +274,9 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
var (
portID string
hostAccount string

initialChannelID = "channel-1"
channelIDAfterReopening = "channel-2"
)

t.Run("register interchain account", func(t *testing.T) {
Expand All @@ -301,8 +299,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
s.Require().NoError(err)
s.Require().NotZero(len(hostAccount))

chanNumber++
_, err = s.QueryChannel(ctx, chainA, portID, "channel-"+strconv.Itoa(chanNumber-1))
_, err = s.QueryChannel(ctx, chainA, portID, initialChannelID)
s.Require().NoError(err)
})

Expand Down Expand Up @@ -362,7 +359,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
})

t.Run("verify channel is closed due to timeout on ordered channel", func(t *testing.T) {
channel, err := s.QueryChannel(ctx, chainA, portID, "channel-"+strconv.Itoa(chanNumber-1))
channel, err := s.QueryChannel(ctx, chainA, portID, initialChannelID)
s.Require().NoError(err)

s.Require().Equal(channeltypes.CLOSED, channel.State, "the channel was not in an expected state")
Expand Down Expand Up @@ -391,8 +388,7 @@ func (s *InterchainAccountsTestSuite) TestMsgSendTx_SuccessfulTransfer_AfterReop
})

t.Run("verify new channel is now open and interchain account has been reregistered with the same portID", func(t *testing.T) {
chanNumber++
channel, err := s.QueryChannel(ctx, chainA, portID, "channel-"+strconv.Itoa(chanNumber-1))
channel, err := s.QueryChannel(ctx, chainA, portID, channelIDAfterReopening)
s.Require().NoError(err)

s.Require().Equal(channeltypes.OPEN, channel.State, "the channel was not in an expected state")
Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/interchain_accounts/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ func (s *GovInterchainAccountsTestSuite) TestInterchainAccountsGovIntegration()
s.Require().NotZero(len(interchainAccAddr))

channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
chanNumber++
s.Require().NoError(err)
s.Require().Equal(len(channels), chanNumber)
s.Require().Equal(len(channels), 2)
})

t.Run("interchain account executes a bank transfer on behalf of the corresponding owner account", func(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/interchain_accounts/groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ func (s *InterchainAccountsTestSuite) TestInterchainAccountsGroupsIntegration()
s.Require().NoError(err)

channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
chanNumber++
s.Require().NoError(err)
s.Require().Equal(len(channels), chanNumber) // 1 transfer (created by default), 1 interchain-accounts
s.Require().Equal(len(channels), 2) // 1 transfer (created by default), 1 interchain-accounts
})

t.Run("fund interchain account wallet", func(t *testing.T) {
Expand Down
6 changes: 2 additions & 4 deletions e2e/tests/interchain_accounts/incentivized_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_SuccessfulBankSe
s.Require().NotZero(len(interchainAcc))

channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
chanNumber++
s.Require().NoError(err)
s.Require().Equal(len(channels), chanNumber)
s.Require().Equal(len(channels), 2)

// interchain accounts channel at index: 0
channelOutput = channels[0]
Expand Down Expand Up @@ -268,9 +267,8 @@ func (s *IncentivizedInterchainAccountsTestSuite) TestMsgSendTx_FailedBankSend_I
s.Require().NotZero(len(interchainAcc))

channels, err := relayer.GetChannels(ctx, s.GetRelayerExecReporter(), chainA.Config().ChainID)
chanNumber++
s.Require().NoError(err)
s.Require().Equal(len(channels), chanNumber)
s.Require().Equal(len(channels), 2)

// interchain accounts channel at index: 0
channelOutput = channels[0]
Expand Down

0 comments on commit a9089d3

Please sign in to comment.