Skip to content

Commit

Permalink
Merge branch 'main' into carlos/run-all-tests-go-mods
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitrisJim authored Sep 26, 2023
2 parents 53f97eb + 0364aae commit a09bf24
Show file tree
Hide file tree
Showing 25 changed files with 710 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compatibility-workflow-call.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
CHAIN_A_TAG: '${{ matrix.chain-a }}'
CHAIN_B_TAG: '${{ matrix.chain-b }}'
CHAIN_BINARY: 'simd'
RELAYER_TYPE: '${{ matrix.relayer-type }}'
RELAYER_ID: '${{ matrix.relayer-type }}'
- name: Upload Diagnostics
uses: actions/upload-artifact@v3
# we only want to upload logs on test failures.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
CHAIN_B_TAG: '${{ inputs.chain-b-tag }}'
RELAYER_IMAGE: '${{ inputs.relayer-image }}'
RELAYER_TAG: '${{ inputs.relayer-tag }}'
RELAYER_TYPE: '${{ inputs.relayer-type }}'
RELAYER_ID: '${{ inputs.relayer-type }}'
CHAIN_BINARY: '${{ inputs.chain-binary }}'
CHAIN_UPGRADE_TAG: '${{ inputs.chain-upgrade-tag }}'
CHAIN_UPGRADE_PLAN: '${{ inputs.upgrade-plan-name }}'
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/e2e-upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
upgrade-v5-hermes:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -27,7 +27,7 @@ jobs:
relayer-type: hermes

upgrade-v7-hermes:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -41,7 +41,7 @@ jobs:
relayer-type: hermes

upgrade-v7_1-hermes:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -55,7 +55,7 @@ jobs:
relayer-type: hermes

upgrade-v8-hermes:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -69,7 +69,7 @@ jobs:
relayer-type: hermes

upgrade-v5-rly:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -85,7 +85,7 @@ jobs:
relayer-tag: latest

upgrade-v7-rly:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -101,7 +101,7 @@ jobs:
relayer-tag: latest

upgrade-v7_1-rly:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand All @@ -117,7 +117,7 @@ jobs:
relayer-tag: latest

upgrade-v8-rly:
uses: cosmos/ibc-go/.github/workflows/e2e-test-workflow-call.yml@main
uses: .github/workflows/e2e-test-workflow-call.yml
with:
chain-image: ghcr.io/cosmos/ibc-go-simd
chain-binary: simd
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ ARG IBC_GO_VERSION
RUN set -eux; apk add --no-cache git libusb-dev linux-headers gcc musl-dev make;

ENV GOPATH=""
ENV GOMODULE="on"

# ensure the ibc go version is being specified for this image.
RUN test -n "${IBC_GO_VERSION}"
Expand Down
2 changes: 1 addition & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ options specified in your config file.
| CHAIN_B_TAG | The tag used for chain A | latest |
| CHAIN_BINARY | The binary used in the container | simd |
| RELAYER_TAG | The tag used for the relayer | main |
| RELAYER_TYPE | The type of relayer to use (rly/hermes) | rly |
| RELAYER_ID | The type of relayer to use (rly/hermes) | hermes |

> Note: when running tests locally, **no images are pushed** to the `ghcr.io/cosmos/ibc-go-simd` registry.
The images which are used only exist on your machine.
Expand Down
16 changes: 4 additions & 12 deletions e2e/relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ const (
type Config struct {
// Tag is the tag used for the relayer image.
Tag string `yaml:"tag"`
// Type specifies the type of relayer that this is.
Type string `yaml:"type"`
// ID specifies the type of relayer that this is.
ID string `yaml:"id"`
// Image is the image that should be used for the relayer.
Image string `yaml:"image"`
}

// New returns an implementation of ibc.Relayer depending on the provided RelayerType.
func New(t *testing.T, cfg Config, logger *zap.Logger, dockerClient *dockerclient.Client, network string) ibc.Relayer {
t.Helper()
switch cfg.Type {
switch cfg.ID {
case Rly:
return newCosmosRelayer(t, cfg.Tag, logger, dockerClient, network, cfg.Image)
case Hermes:
return newHermesRelayer(t, cfg.Tag, logger, dockerClient, network, cfg.Image)
default:
panic(fmt.Errorf("unknown relayer specified: %s", cfg.Type))
panic(fmt.Errorf("unknown relayer specified: %s", cfg.ID))
}
}

Expand All @@ -49,10 +49,6 @@ func New(t *testing.T, cfg Config, logger *zap.Logger, dockerClient *dockerclien
func newCosmosRelayer(t *testing.T, tag string, logger *zap.Logger, dockerClient *dockerclient.Client, network, relayerImage string) ibc.Relayer {
t.Helper()

if relayerImage == "" {
relayerImage = RlyRelayerRepository
}

customImageOption := relayer.CustomDockerImage(relayerImage, tag, rlyRelayerUser)
relayerProcessingOption := relayer.StartupFlags("-p", "events") // relayer processes via events

Expand All @@ -67,10 +63,6 @@ func newCosmosRelayer(t *testing.T, tag string, logger *zap.Logger, dockerClient
func newHermesRelayer(t *testing.T, tag string, logger *zap.Logger, dockerClient *dockerclient.Client, network, relayerImage string) ibc.Relayer {
t.Helper()

if relayerImage == "" {
relayerImage = HermesRelayerRepository
}

customImageOption := relayer.CustomDockerImage(relayerImage, tag, hermesRelayerUser)
relayerFactory := interchaintest.NewBuiltinRelayerFactory(ibc.Hermes, logger, customImageOption)

Expand Down
12 changes: 8 additions & 4 deletions e2e/sample.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ chains:
tag: main # override with CHAIN_B_TAG
binary: simd # override with CHAIN_BINARY

relayer:
type: hermes # override with RELAYER_TYPE
image: ghcr.io/informalsystems/hermes # override with RELAYER_IMAGE
tag: "bef2f53" # override with RELAYER_TAG
activeRelayer: hermes # override with RELAYER_ID
relayers:
- id: hermes
image: ghcr.io/informalsystems/hermes
tag: "bef2f53"
- id: rly
image: ghcr.io/cosmos/relayer
tag: "latest"

cometbft:
logLevel: info
Expand Down
124 changes: 118 additions & 6 deletions e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
test "github.com/strangelove-ventures/interchaintest/v8/testutil"
testifysuite "github.com/stretchr/testify/suite"

"cosmossdk.io/x/upgrade/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
Expand Down Expand Up @@ -85,6 +85,7 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() {
chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

const planHeight = int64(75)
const legacyPlanHeight = planHeight * 2
var newChainID string

t.Run("execute proposal for MsgIBCSoftwareUpgrade", func(t *testing.T) {
Expand All @@ -107,14 +108,14 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() {

scheduleUpgradeMsg, err := clienttypes.NewMsgIBCSoftwareUpgrade(
authority.String(),
types.Plan{
upgradetypes.Plan{
Name: "upgrade-client",
Height: planHeight,
},
upgradedClientState,
)
s.Require().NoError(err)
s.ExecuteGovV1Proposal(ctx, scheduleUpgradeMsg, chainA, chainAWallet)
s.ExecuteAndPassGovV1Proposal(ctx, scheduleUpgradeMsg, chainA, chainAWallet)
})

t.Run("check that IBC software upgrade has been scheduled successfully on chainA", func(t *testing.T) {
Expand All @@ -132,6 +133,117 @@ func (s *ClientTestSuite) TestScheduleIBCUpgrade_Succeeds() {
s.Require().Equal("upgrade-client", plan.Name)
s.Require().Equal(planHeight, plan.Height)
})

t.Run("ensure legacy proposal does not succeed", func(t *testing.T) {

authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA)
s.Require().NoError(err)
s.Require().NotNil(authority)

clientState, err := s.QueryClientState(ctx, chainB, ibctesting.FirstClientID)
s.Require().NoError(err)

originalChainID := clientState.(*ibctm.ClientState).ChainId
revisionNumber := clienttypes.ParseChainID(originalChainID)
// increment revision number even with new chain ID to prevent loss of misbehaviour detection support
newChainID, err = clienttypes.SetRevisionNumber(originalChainID, revisionNumber+1)
s.Require().NoError(err)
s.Require().NotEqual(originalChainID, newChainID)

upgradedClientState := clientState.ZeroCustomFields().(*ibctm.ClientState)
upgradedClientState.ChainId = newChainID

legacyUpgradeProposal, err := clienttypes.NewUpgradeProposal(ibctesting.Title, ibctesting.Description, upgradetypes.Plan{
Name: "upgrade-client-legacy",
Height: legacyPlanHeight,
}, upgradedClientState)

s.Require().NoError(err)
txResp := s.ExecuteGovV1Beta1Proposal(ctx, chainA, chainAWallet, legacyUpgradeProposal)
s.AssertTxFailure(txResp, govtypes.ErrInvalidProposalContent)
})
}

func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() {
t := s.T()
ctx := context.TODO()

var (
pathName string
relayer ibc.Relayer
subjectClientID string
substituteClientID string
// set the trusting period to a value which will still be valid upon client creation, but invalid before the first update
badTrustingPeriod = time.Second * 10
)

t.Run("create substitute client with correct trusting period", func(t *testing.T) {
relayer, _ = s.SetupChainsRelayerAndChannel(ctx)

// TODO: update when client identifier created is accessible
// currently assumes first client is 07-tendermint-0
substituteClientID = clienttypes.FormatClientIdentifier(ibcexported.Tendermint, 0)

// TODO: replace with better handling of path names
pathName = fmt.Sprintf("%s-path-%d", s.T().Name(), 0)
pathName = strings.ReplaceAll(pathName, "/", "-")
})

chainA, chainB := s.GetChains()
chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

t.Run("create subject client with bad trusting period", func(t *testing.T) {
createClientOptions := ibc.CreateClientOptions{
TrustingPeriod: badTrustingPeriod.String(),
}

s.SetupClients(ctx, relayer, createClientOptions)

// TODO: update when client identifier created is accessible
// currently assumes second client is 07-tendermint-1
subjectClientID = clienttypes.FormatClientIdentifier(ibcexported.Tendermint, 1)
})

time.Sleep(badTrustingPeriod)

t.Run("update substitute client", func(t *testing.T) {
s.UpdateClients(ctx, relayer, pathName)
})

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

t.Run("check status of each client", func(t *testing.T) {
t.Run("substitute should be active", func(t *testing.T) {
status, err := s.Status(ctx, chainA, substituteClientID)
s.Require().NoError(err)
s.Require().Equal(ibcexported.Active.String(), status)
})

t.Run("subject should be expired", func(t *testing.T) {
status, err := s.Status(ctx, chainA, subjectClientID)
s.Require().NoError(err)
s.Require().Equal(ibcexported.Expired.String(), status)
})
})

t.Run("pass client update proposal", func(t *testing.T) {
proposal := clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subjectClientID, substituteClientID)
s.ExecuteAndPassGovV1Beta1Proposal(ctx, chainA, chainAWallet, proposal)
})

t.Run("check status of each client", func(t *testing.T) {
t.Run("substitute should be active", func(t *testing.T) {
status, err := s.Status(ctx, chainA, substituteClientID)
s.Require().NoError(err)
s.Require().Equal(ibcexported.Active.String(), status)
})

t.Run("subject should be active", func(t *testing.T) {
status, err := s.Status(ctx, chainA, subjectClientID)
s.Require().NoError(err)
s.Require().Equal(ibcexported.Active.String(), status)
})
})
}

// TestRecoverClient_Succeeds tests that a governance proposal to recover a client using a MsgRecoverClient is successful.
Expand Down Expand Up @@ -202,7 +314,7 @@ func (s *ClientTestSuite) TestRecoverClient_Succeeds() {
s.Require().NoError(err)
recoverClientMsg := clienttypes.NewMsgRecoverClient(authority.String(), subjectClientID, substituteClientID)
s.Require().NotNil(recoverClientMsg)
s.ExecuteGovV1Proposal(ctx, recoverClientMsg, chainA, chainAWallet)
s.ExecuteAndPassGovV1Proposal(ctx, recoverClientMsg, chainA, chainAWallet)
})

t.Run("check status of each client", func(t *testing.T) {
Expand Down Expand Up @@ -353,7 +465,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() {
s.Require().NotNil(authority)

msg := clienttypes.NewMsgUpdateParams(authority.String(), clienttypes.NewParams(allowedClient))
s.ExecuteGovV1Proposal(ctx, msg, chainA, chainAWallet)
s.ExecuteAndPassGovV1Proposal(ctx, msg, chainA, chainAWallet)
} else {
value, err := tmjson.Marshal([]string{allowedClient})
s.Require().NoError(err)
Expand All @@ -362,7 +474,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() {
}

proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovV1Beta1Proposal(ctx, chainA, chainAWallet, proposal)
s.ExecuteAndPassGovV1Beta1Proposal(ctx, chainA, chainAWallet, proposal)
}
})

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() {
s.Require().NotNil(authority)

msg := connectiontypes.NewMsgUpdateParams(authority.String(), connectiontypes.NewParams(delay))
s.ExecuteGovV1Proposal(ctx, msg, chainA, chainAWallet)
s.ExecuteAndPassGovV1Proposal(ctx, msg, chainA, chainAWallet)
} else {
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(ibcexported.ModuleName, string(connectiontypes.KeyMaxExpectedTimePerBlock), fmt.Sprintf(`"%d"`, delay)),
}

proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovV1Beta1Proposal(ctx, chainA, chainAWallet, proposal)
s.ExecuteAndPassGovV1Beta1Proposal(ctx, chainA, chainAWallet, proposal)
}
})

Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/interchain_accounts/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration()
t.Run("execute proposal for MsgRegisterInterchainAccount", func(t *testing.T) {
version := icatypes.NewDefaultMetadataString(ibctesting.FirstConnectionID, ibctesting.FirstConnectionID)
msgRegisterAccount := controllertypes.NewMsgRegisterInterchainAccount(ibctesting.FirstConnectionID, govModuleAddress.String(), version)
s.ExecuteGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount)
s.ExecuteAndPassGovV1Proposal(ctx, msgRegisterAccount, chainA, controllerAccount)
})

t.Run("start relayer", func(t *testing.T) {
Expand Down Expand Up @@ -104,7 +104,7 @@ func (s *InterchainAccountsGovTestSuite) TestInterchainAccountsGovIntegration()
}

msgSendTx := controllertypes.NewMsgSendTx(govModuleAddress.String(), ibctesting.FirstConnectionID, uint64(time.Hour.Nanoseconds()), packetData)
s.ExecuteGovV1Proposal(ctx, msgSendTx, chainA, controllerAccount)
s.ExecuteAndPassGovV1Proposal(ctx, msgSendTx, chainA, controllerAccount)
})

t.Run("verify tokens transferred", func(t *testing.T) {
Expand Down
Loading

0 comments on commit a09bf24

Please sign in to comment.