Skip to content

Commit

Permalink
chore: bump ibctest version and ibc-go version to v6 for e2e module (#…
Browse files Browse the repository at this point in the history
…2479)

## Description

closes: #XXXX

---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [ ] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Codecov Report` in the comment section below once CI passes

(cherry picked from commit 4bd05c6)

# Conflicts:
#	e2e/go.mod
#	e2e/go.sum
#	e2e/testconfig/testconfig.go
#	e2e/tests/core/client_test.go
#	e2e/tests/interchain_accounts/base_test.go
#	e2e/tests/interchain_accounts/incentivized_test.go
#	e2e/tests/transfer/base_test.go
#	e2e/tests/transfer/incentivized_test.go
#	e2e/tests/upgrades/upgrade_test.go
#	e2e/testsuite/grpc_query.go
#	e2e/testsuite/relayer.go
#	e2e/testsuite/testsuite.go
  • Loading branch information
colin-axner authored and mergify[bot] committed Nov 11, 2022
1 parent f0928ba commit 1528713
Show file tree
Hide file tree
Showing 13 changed files with 2,775 additions and 433 deletions.
24 changes: 23 additions & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@ go 1.18
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

require (
<<<<<<< HEAD
github.com/cosmos/cosmos-sdk v0.46.0
github.com/cosmos/ibc-go/v5 v5.0.0-beta1
github.com/docker/docker v20.10.17+incompatible
github.com/strangelove-ventures/ibctest v0.0.0-20220808203516-6cbd3743756d
github.com/stretchr/testify v1.8.0
go.uber.org/zap v1.21.0
google.golang.org/grpc v1.48.0
=======
github.com/cosmos/cosmos-sdk v0.46.1
github.com/cosmos/ibc-go/v6 v6.0.0-alpha1
github.com/cosmos/interchain-accounts v0.3.1-0.20220816085955-393d8444c111
github.com/docker/docker v20.10.17+incompatible
github.com/strangelove-ventures/ibctest/v6 v6.0.0-20221005154709-b642157674bc
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.21
go.uber.org/zap v1.21.0
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
google.golang.org/grpc v1.49.0
>>>>>>> 4bd05c6 (chore: bump ibctest version and ibc-go version to v6 for e2e module (#2479))
)

require (
Expand All @@ -20,7 +33,7 @@ require (
cloud.google.com/go/iam v0.3.0 // indirect
cloud.google.com/go/storage v1.14.0 // indirect
cosmossdk.io/errors v1.0.0-beta.7 // indirect
cosmossdk.io/math v1.0.0-beta.2 // indirect
cosmossdk.io/math v1.0.0-beta.3 // indirect
filippo.io/edwards25519 v1.0.0-rc.1 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
Expand Down Expand Up @@ -138,8 +151,13 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
<<<<<<< HEAD
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
=======
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect
>>>>>>> 4bd05c6 (chore: bump ibctest version and ibc-go version to v6 for e2e module (#2479))
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
Expand All @@ -154,7 +172,11 @@ require (
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
<<<<<<< HEAD
gotest.tools/v3 v3.3.0 // indirect
=======
lukechampine.com/blake3 v1.1.6 // indirect
>>>>>>> 4bd05c6 (chore: bump ibctest version and ibc-go version to v6 for e2e module (#2479))
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.36.0 // indirect
modernc.org/ccgo/v3 v3.16.6 // indirect
Expand Down
879 changes: 465 additions & 414 deletions e2e/go.sum

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions e2e/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ import (
"fmt"
"os"

<<<<<<< HEAD
"github.com/strangelove-ventures/ibctest/ibc"
=======
"github.com/cosmos/cosmos-sdk/codec"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/strangelove-ventures/ibctest/v6/ibc"
tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/ibc-go/e2e/testvalues"
>>>>>>> 4bd05c6 (chore: bump ibctest version and ibc-go version to v6 for e2e module (#2479))
)

const (
Expand Down Expand Up @@ -89,5 +103,57 @@ func newDefaultSimappConfig(tc TestConfig, name, chainID, denom string) ibc.Chai
GasAdjustment: 1.3,
TrustingPeriod: "508h",
NoHostMount: false,
<<<<<<< HEAD
=======
ModifyGenesis: defaultModifyGenesis(),
}
}

// defaultModifyGenesis will only modify governance params to ensure the voting period and minimum deposit
// are functional for e2e testing purposes.
func defaultModifyGenesis() func(ibc.ChainConfig, []byte) ([]byte, error) {
return func(chainConfig ibc.ChainConfig, genbz []byte) ([]byte, error) {
genDoc, err := tmtypes.GenesisDocFromJSON(genbz)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes into genesis doc: %w", err)
}

var appState genutiltypes.AppMap
if err := json.Unmarshal(genDoc.AppState, &appState); err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes into app state: %w", err)
}

cfg := simappparams.MakeTestEncodingConfig()
govv1beta1.RegisterInterfaces(cfg.InterfaceRegistry)
cdc := codec.NewProtoCodec(cfg.InterfaceRegistry)

govGenesisState := &govv1beta1.GenesisState{}
if err := cdc.UnmarshalJSON(appState[govtypes.ModuleName], govGenesisState); err != nil {
return nil, fmt.Errorf("failed to unmarshal genesis bytes into gov genesis state: %w", err)
}

// set correct minimum deposit using configured denom
govGenesisState.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin(chainConfig.Denom, govv1beta1.DefaultMinDepositTokens))
govGenesisState.VotingParams.VotingPeriod = testvalues.VotingPeriod

govGenBz, err := cdc.MarshalJSON(govGenesisState)
if err != nil {
return nil, fmt.Errorf("failed to marshal gov genesis state: %w", err)
}

appState[govtypes.ModuleName] = govGenBz

genDoc.AppState, err = json.Marshal(appState)
if err != nil {
return nil, err
}

bz, err := tmjson.MarshalIndent(genDoc, "", " ")
if err != nil {
return nil, err
}

return bz, nil
>>>>>>> 4bd05c6 (chore: bump ibctest version and ibc-go version to v6 for e2e module (#2479))
}
}
121 changes: 121 additions & 0 deletions e2e/tests/core/client_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package e2e

import (
"context"
"fmt"
"strings"
"testing"
"time"

"github.com/strangelove-ventures/ibctest/v6/ibc"
"github.com/strangelove-ventures/ibctest/v6/test"
"github.com/stretchr/testify/suite"

"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v6/modules/core/exported"
ibctesting "github.com/cosmos/ibc-go/v6/testing"
)

func TestClientTestSuite(t *testing.T) {
suite.Run(t, new(ClientTestSuite))
}

type ClientTestSuite struct {
testsuite.E2ETestSuite
}

// Status queries the current status of the client
func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID string) (string, error) {
queryClient := s.GetChainGRCPClients(chain).ClientQueryClient
res, err := queryClient.ClientStatus(ctx, &clienttypes.QueryClientStatusRequest{
ClientId: clientID,
})
if err != nil {
return "", err
}

return res.Status, nil
}

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

var (
pathName string
relayer ibc.Relayer
subjectClientID string
substituteClientID string
badTrustingPeriod = time.Duration(time.Second)
)

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.ExecuteGovProposal(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)
})
})
}
Loading

0 comments on commit 1528713

Please sign in to comment.