Skip to content
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

test: adding e2e upgrade test for v7.1 localhost #3164

Merged
merged 13 commits into from
Feb 21, 2023
8 changes: 7 additions & 1 deletion .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ jobs:
chain-binary: simd
chain-a-tag: v6.1.0
chain-b-tag: v6.1.0
chain-upgrade-tag: v7.0.0-rc0 # TODO: needs v7.0.0-rc1 when cut
chain-upgrade-tag: pr-3136 # TODO: needs v7.0.0-rc1 when cut
- test: TestV7ChainUpgradeAddLocalhost
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
chain-a-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut
chain-b-tag: pr-3136 # TODO: needs v7.0.0 (with simapp fixes) when cut
chain-upgrade-tag: pr-3164 # TODO: needs v7.1.0 when cut
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
Expand Down
35 changes: 33 additions & 2 deletions e2e/tests/upgrades/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import (
icatypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/types"
v7migrations "github.com/cosmos/ibc-go/v7/modules/core/02-client/migrations/v7"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
solomachine "github.com/cosmos/ibc-go/v7/modules/light-clients/06-solomachine"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
simappupgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades"
v5 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v5"
v7upgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7"
v71 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7.1"
)

const (
Expand Down Expand Up @@ -150,7 +152,7 @@ func (s *UpgradeTestSuite) TestV4ToV5ChainUpgrade() {
s.Require().NoError(test.WaitForBlocks(ctx, 5, chainA, chainB), "failed to wait for blocks")

t.Run("upgrade chainA", func(t *testing.T) {
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, simappupgrades.DefaultUpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
s.UpgradeChain(ctx, chainA, chainAUpgradeProposalWallet, v5.UpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
})

t.Run("restart relayer", func(t *testing.T) {
Expand Down Expand Up @@ -549,6 +551,35 @@ func (s *UpgradeTestSuite) TestV6ToV7ChainUpgrade() {
})
}

func (s *UpgradeTestSuite) TestV7ChainUpgradeAddLocalhost() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love how simple this test is 🥇

t := s.T()
testCfg := testconfig.FromEnv()

ctx := context.Background()
_, _ = s.SetupChainsRelayerAndChannel(ctx)
chain, _ := s.GetChains()

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

t.Run("upgrade chain", func(t *testing.T) {
govProposalWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)
s.UpgradeChain(ctx, chain, govProposalWallet, v71.UpgradeName, testCfg.ChainAConfig.Tag, testCfg.UpgradeTag)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated! need to get the fix in #3172 included in this branch too. The else if we added earlier caused some weird issues in CI.

})

t.Run("ensure the localhost client is active and sentinel connection is stored in state", func(t *testing.T) {
status, err := s.QueryClientStatus(ctx, chain, exported.Localhost)
s.Require().NoError(err)
s.Require().Equal(exported.Active.String(), status)

connectionEnd, err := s.QueryConnection(ctx, chain, connectiontypes.LocalhostID)
s.Require().NoError(err)
s.Require().Equal(connectiontypes.OPEN, connectionEnd.State)
s.Require().Equal(exported.Localhost, connectionEnd.ClientId)
s.Require().Equal(exported.Localhost, connectionEnd.Counterparty.ClientId)
s.Require().Equal(connectiontypes.LocalhostID, connectionEnd.Counterparty.ConnectionId)
})
}

// RegisterInterchainAccount will attempt to register an interchain account on the counterparty chain.
func (s *UpgradeTestSuite) RegisterInterchainAccount(ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, msgRegisterAccount *intertxtypes.MsgRegisterAccount) error {
txResp, err := s.BroadcastMessages(ctx, chain, user, msgRegisterAccount)
Expand Down
14 changes: 14 additions & 0 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
controllertypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/types"
feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
)
Expand Down Expand Up @@ -47,6 +48,19 @@ func (s *E2ETestSuite) QueryClientStatus(ctx context.Context, chain ibc.Chain, c
return res.Status, nil
}

// QueryConnection queries
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
func (s *E2ETestSuite) QueryConnection(ctx context.Context, chain ibc.Chain, connectionID string) (connectiontypes.ConnectionEnd, error) {
queryClient := s.GetChainGRCPClients(chain).ConnectionQueryClient
res, err := queryClient.Connection(ctx, &connectiontypes.QueryConnectionRequest{
ConnectionId: connectionID,
})
if err != nil {
return connectiontypes.ConnectionEnd{}, err
}

return *res.Connection, nil
}

// QueryChannel queries the channel on a given chain for the provided portID and channelID
func (s *E2ETestSuite) QueryChannel(ctx context.Context, chain ibc.Chain, portID, channelID string) (channeltypes.Channel, error) {
queryClient := s.GetChainGRCPClients(chain).ChannelQueryClient
Expand Down
35 changes: 19 additions & 16 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
feetypes "github.com/cosmos/ibc-go/v7/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types"
)

Expand Down Expand Up @@ -70,11 +71,12 @@ type E2ETestSuite struct {
// These should typically be used for query clients only. If we need to make changes, we should
// use E2ETestSuite.BroadcastMessages to broadcast transactions instead.
type GRPCClients struct {
ClientQueryClient clienttypes.QueryClient
ChannelQueryClient channeltypes.QueryClient
FeeQueryClient feetypes.QueryClient
ICAQueryClient controllertypes.QueryClient
InterTxQueryClient intertxtypes.QueryClient
ClientQueryClient clienttypes.QueryClient
ConnectionQueryClient connectiontypes.QueryClient
ChannelQueryClient channeltypes.QueryClient
FeeQueryClient feetypes.QueryClient
ICAQueryClient controllertypes.QueryClient
InterTxQueryClient intertxtypes.QueryClient

// SDK query clients
GovQueryClient govtypesv1beta1.QueryClient
Expand Down Expand Up @@ -382,17 +384,18 @@ func (s *E2ETestSuite) InitGRPCClients(chain *cosmos.CosmosChain) {
}

s.grpcClients[chain.Config().ChainID] = GRPCClients{
ClientQueryClient: clienttypes.NewQueryClient(grpcConn),
ChannelQueryClient: channeltypes.NewQueryClient(grpcConn),
FeeQueryClient: feetypes.NewQueryClient(grpcConn),
ICAQueryClient: controllertypes.NewQueryClient(grpcConn),
InterTxQueryClient: intertxtypes.NewQueryClient(grpcConn),
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn),
AuthQueryClient: authtypes.NewQueryClient(grpcConn),
AuthZQueryClient: authz.NewQueryClient(grpcConn),
ClientQueryClient: clienttypes.NewQueryClient(grpcConn),
ConnectionQueryClient: connectiontypes.NewQueryClient(grpcConn),
ChannelQueryClient: channeltypes.NewQueryClient(grpcConn),
FeeQueryClient: feetypes.NewQueryClient(grpcConn),
ICAQueryClient: controllertypes.NewQueryClient(grpcConn),
InterTxQueryClient: intertxtypes.NewQueryClient(grpcConn),
GovQueryClient: govtypesv1beta1.NewQueryClient(grpcConn),
GovQueryClientV1: govtypesv1.NewQueryClient(grpcConn),
GroupsQueryClient: grouptypes.NewQueryClient(grpcConn),
ParamsQueryClient: paramsproposaltypes.NewQueryClient(grpcConn),
AuthQueryClient: authtypes.NewQueryClient(grpcConn),
AuthZQueryClient: authz.NewQueryClient(grpcConn),
}
}

Expand Down
9 changes: 8 additions & 1 deletion testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ import (
ibcmock "github.com/cosmos/ibc-go/v7/testing/mock"
simappparams "github.com/cosmos/ibc-go/v7/testing/simapp/params"
simappupgrades "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades"
v5 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v5"
v6 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v6"
v7 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7"
v71 "github.com/cosmos/ibc-go/v7/testing/simapp/upgrades/v7.1"
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types"
)

Expand Down Expand Up @@ -929,7 +931,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// setupUpgradeHandlers sets all necessary upgrade handlers for testing purposes
func (app *SimApp) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(
simappupgrades.DefaultUpgradeName,
v5.UpgradeName,
simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator),
)

Expand Down Expand Up @@ -960,6 +962,11 @@ func (app *SimApp) setupUpgradeHandlers() {
app.ParamsKeeper,
),
)

app.UpgradeKeeper.SetUpgradeHandler(
v71.UpgradeName,
simappupgrades.CreateDefaultUpgradeHandler(app.mm, app.configurator),
)
}

// setupUpgradeStoreLoaders sets all necessary store loaders required by upgrades.
Expand Down
5 changes: 0 additions & 5 deletions testing/simapp/upgrades/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

const (
// DefaultUpgradeName is the default upgrade name used for upgrade tests which do not require special handling.
DefaultUpgradeName = "normal upgrade"
)

// CreateDefaultUpgradeHandler creates an upgrade handler which can be used for regular upgrade tests
// that do not require special logic
func CreateDefaultUpgradeHandler(
Expand Down
6 changes: 6 additions & 0 deletions testing/simapp/upgrades/v5/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package v5

const (
// UpgradeName defines the on-chain upgrade name for the SimApp v5 upgrade.
UpgradeName = "normal upgrade" // NOTE: keeping as "normal upgrade" as existing tags depend on this name
)
6 changes: 6 additions & 0 deletions testing/simapp/upgrades/v7.1/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package v71

const (
// UpgradeName defines the on-chain upgrade name for the SimApp v7.1 upgrade.
UpgradeName = "v7.1 - localhost"
)