Skip to content

Commit

Permalink
test: add v8 to v9 e2e upgrade tests with channel upgrade (#6806)
Browse files Browse the repository at this point in the history
* test: channel upgrade after v8->v9 upgrade

* Add upgrades with channel upgrades to ci

* use multi-denom transfer in v8 upgrade channel upgrade test

* update e2e upgrade ci test tag with pr tag

* cr fixes

* cr fixes

* remove rly channel-upgrade test

* fix rly for upgrade test
  • Loading branch information
gjermundgaraba authored Jul 13, 2024
1 parent fb51220 commit 794b265
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 6 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
chain-upgrade-tag: v8.1.0
upgrade-plan-name: "v8.1"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV8ToV8_1ChainUpgrade_ChannelUpgrades"
test: "TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade"
upload-logs: true
relayer-type: hermes

Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
chain-binary: simd
chain-a-tag: v8.3.2
chain-b-tag: v8.3.2
chain-upgrade-tag: pr-6791 # TODO: Update tag to v9.0.0 once it is (pre)released
chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released
upgrade-plan-name: "v9"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV8ToV9ChainUpgrade"
Expand All @@ -181,7 +181,7 @@ jobs:
chain-binary: simd
chain-a-tag: v8.3.2
chain-b-tag: v8.3.2
chain-upgrade-tag: pr-6791 # TODO: Update tag to v9.0.0 once it is (pre)released
chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released
upgrade-plan-name: "v9"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV8ToV9ChainUpgrade"
Expand All @@ -197,9 +197,23 @@ jobs:
chain-binary: simd
chain-a-tag: v8.3.2
chain-b-tag: v8.3.2
chain-upgrade-tag: pr-6791 # TODO: Update tag to v9.0.0 once it is (pre)released
chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released
upgrade-plan-name: "v9"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV8ToV9ChainUpgrade_Localhost"
upload-logs: true
relayer-type: hermes
relayer-type: hermes

upgrade-v9-channel-upgrades-hermes:
uses: ./.github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
chain-a-tag: v8.3.2
chain-b-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released
chain-upgrade-tag: main # TODO: Update tag to v9.0.0 once it is (pre)released
upgrade-plan-name: "v9"
test-entry-point: "TestUpgradeTestSuite"
test: "TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade"
upload-logs: true
relayer-type: hermes
107 changes: 106 additions & 1 deletion e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade() {
})
}

func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_ChannelUpgrades() {
func (s *UpgradeTestSuite) TestV8ToV8_1ChainUpgrade_FeeMiddlewareChannelUpgrade() {
t := s.T()
testCfg := testsuite.LoadConfig()
ctx := context.Background()
Expand Down Expand Up @@ -1093,11 +1093,19 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade() {

s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA), "failed to wait for blocks")

t.Run("stop relayer", func(t *testing.T) {
s.StopRelayer(ctx, relayer)
})

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("start relayer", func(t *testing.T) {
s.StartRelayer(relayer, testName)
})

t.Run("query denoms after upgrade", func(t *testing.T) {
resp, err := query.TransferDenoms(ctx, chainA)
s.Require().NoError(err)
Expand Down Expand Up @@ -1277,6 +1285,103 @@ func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_Localhost() {
})
}

func (s *UpgradeTestSuite) TestV8ToV9ChainUpgrade_ICS20v2ChannelUpgrade() {
t := s.T()
testCfg := testsuite.LoadConfig()
ctx := context.Background()

testName := t.Name()

relayer, channelA := s.CreateUpgradeTestPath(testName)

chainA, chainB := s.GetChains()
chainADenom := chainA.Config().Denom
chainBDenom := chainB.Config().Denom

chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
chainAAddress := chainAWallet.FormattedAddress()

chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
chainBAddress := chainBWallet.FormattedAddress()

chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks")

t.Run("start relayer", func(t *testing.T) {
s.StartRelayer(relayer, testName)
})

t.Run("transfer native tokens from chainA to chainB", func(t *testing.T) {
transferTxResp := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferCoins(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0, "")
s.AssertTxSuccess(transferTxResp)

s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1)

actualBalance, err := query.Balance(ctx, chainB, chainBAddress, chainBIBCToken.IBCDenom())
s.Require().NoError(err)

expected := testvalues.IBCTransferAmount
s.Require().Equal(expected, actualBalance.Int64())
})

t.Run("verify channel version before upgrade", func(t *testing.T) {
channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID)
s.Require().NoError(err)
s.Require().Equal(transfertypes.V1, channel.Version, "the channel version is not ics20-1")
})

s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA), "failed to wait for blocks")

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chainA.(*cosmos.CosmosChain), govProposalWallet, testCfg.UpgradeConfig.PlanName, testCfg.ChainConfigs[0].Tag, testCfg.UpgradeConfig.Tag)
})

t.Run("upgrade channel to ics20-2", func(t *testing.T) {
chA, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID)
s.Require().NoError(err)

upgradeFields := channeltypes.NewUpgradeFields(chA.Ordering, chA.ConnectionHops, transfertypes.V2)
s.InitiateChannelUpgrade(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, upgradeFields)
})

t.Run("verify channel A upgraded and transfer version is ics20-2", func(t *testing.T) {
err := test.WaitForCondition(time.Minute*2, time.Second*2, func() (bool, error) {
channel, err := query.Channel(ctx, chainA, channelA.PortID, channelA.ChannelID)
if err != nil {
return false, err
}

return channel.Version == transfertypes.V2, nil
})
s.Require().NoError(err, "failed to wait for channel to be upgraded to ics20-2")
})

t.Run("multi-denom IBC token transfer from chainB to chainA, to make sure the upgrade did not break the packet flow", func(t *testing.T) {
transferCoins := []sdk.Coin{
testvalues.DefaultTransferAmount(chainBIBCToken.IBCDenom()),
testvalues.DefaultTransferAmount(chainBDenom),
}

transferTxResp := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, transferCoins, chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "")
s.AssertTxSuccess(transferTxResp)

s.AssertPacketRelayed(ctx, chainB, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 2)

actualNativeBalance, err := chainA.GetBalance(ctx, chainAAddress, chainADenom)
s.Require().NoError(err)
expected := testvalues.StartingTokenAmount
s.Require().Equal(expected, actualNativeBalance.Int64())

chainAIBCToken := testsuite.GetIBCToken(chainBDenom, channelA.PortID, channelA.ChannelID)
actualIBCTokenBalance, err := query.Balance(ctx, chainA, chainAAddress, chainAIBCToken.IBCDenom())
s.Require().NoError(err)
expected = testvalues.IBCTransferAmount
s.Require().Equal(expected, actualIBCTokenBalance.Int64())
})
}

// ClientState queries the current ClientState by clientID
func (*UpgradeTestSuite) ClientState(ctx context.Context, chain ibc.Chain, clientID string) (*clienttypes.QueryClientStateResponse, error) {
res, err := query.GRPCQuery[clienttypes.QueryClientStateResponse](ctx, chain, &clienttypes.QueryClientStateRequest{ClientId: clientID})
Expand Down

0 comments on commit 794b265

Please sign in to comment.