From 46c96bbd1f7579442f92c8ba6c9e6d65ff187113 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Fri, 15 Jul 2022 09:51:04 +0100 Subject: [PATCH] chore: merge with #1710 --- e2e/fee_middleware_test.go | 7 +- e2e/go.mod | 10 +- e2e/go.sum | 4 +- e2e/testconfig/testconfig.go | 47 ++++++ e2e/testsuite/relayer.go | 22 +++ e2e/testsuite/testsuite.go | 279 +++++++++++++++-------------------- 6 files changed, 200 insertions(+), 169 deletions(-) create mode 100644 e2e/testsuite/relayer.go diff --git a/e2e/fee_middleware_test.go b/e2e/fee_middleware_test.go index 64719790413..4f18a5ba9b4 100644 --- a/e2e/fee_middleware_test.go +++ b/e2e/fee_middleware_test.go @@ -12,8 +12,9 @@ import ( "github.com/strangelove-ventures/ibctest/test" "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/v4/e2e/testsuite" - "github.com/cosmos/ibc-go/v4/e2e/testvalues" + "e2e/testsuite" + "e2e/testvalues" + feetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ) @@ -75,7 +76,7 @@ func (s *FeeMiddlewareTestSuite) TestMsgPayPacketFeeAsyncSingleSender() { payPacketFeeTxResp sdk.TxResponse ) - relayer, channelA := s.CreateChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions()) + relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions()) chainA, chainB := s.GetChains() chainADenom := chainA.Config().Denom diff --git a/e2e/go.mod b/e2e/go.mod index f6e4d83a317..5b80823e0f3 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -1,17 +1,14 @@ -module github.com/cosmos/ibc-go/v4/e2e +module e2e go 1.18 replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 require ( - github.com/cosmos/cosmos-sdk v0.45.6 - github.com/cosmos/ibc-go/v4 v4.0.0-rc0 github.com/docker/docker v20.10.17+incompatible - github.com/strangelove-ventures/ibctest v0.0.0-20220708204853-50f4be39c3e9 + github.com/strangelove-ventures/ibctest v0.0.0-20220713213153-930886d8db30 github.com/stretchr/testify v1.8.0 go.uber.org/zap v1.21.0 - google.golang.org/grpc v1.47.0 ) require ( @@ -30,8 +27,10 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect + github.com/cosmos/cosmos-sdk v0.45.6 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/iavl v0.17.3 // indirect + github.com/cosmos/ibc-go/v4 v4.0.0-rc0 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/danieljoos/wincred v1.0.2 // indirect @@ -125,6 +124,7 @@ require ( golang.org/x/tools v0.1.10 // indirect golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect + google.golang.org/grpc v1.47.0 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/e2e/go.sum b/e2e/go.sum index 8efe3d7cac4..6d00db2a409 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -831,8 +831,8 @@ github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5q github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= -github.com/strangelove-ventures/ibctest v0.0.0-20220708204853-50f4be39c3e9 h1:waDZgkN+i3WSeUmDwdMvrNOh3iemGlevWqnznE/PQ0k= -github.com/strangelove-ventures/ibctest v0.0.0-20220708204853-50f4be39c3e9/go.mod h1:aWBeEKU4lGfvJ9qO543zJbQGtB2fK2ffrJh6jbtowEM= +github.com/strangelove-ventures/ibctest v0.0.0-20220713213153-930886d8db30 h1:pMhrxU1tY220nxDu6t/gb0H30NG+WYiSJFS5OrcxLFs= +github.com/strangelove-ventures/ibctest v0.0.0-20220713213153-930886d8db30/go.mod h1:aWBeEKU4lGfvJ9qO543zJbQGtB2fK2ffrJh6jbtowEM= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= diff --git a/e2e/testconfig/testconfig.go b/e2e/testconfig/testconfig.go index 87ef843b282..c043712b4e4 100644 --- a/e2e/testconfig/testconfig.go +++ b/e2e/testconfig/testconfig.go @@ -3,6 +3,8 @@ package testconfig import ( "fmt" "os" + + "github.com/strangelove-ventures/ibctest/ibc" ) const ( @@ -34,3 +36,48 @@ func FromEnv() TestConfig { SimdTag: simdTag, } } + +// ChainOptions stores chain configurations for the chains that will be +// created for the tests. They can be modified by passing ChainOptionConfiguration +// to E2ETestSuite.GetChains. +type ChainOptions struct { + ChainAConfig *ibc.ChainConfig + ChainBConfig *ibc.ChainConfig +} + +// ChainOptionConfiguration enables arbitrary configuration of ChainOptions. +type ChainOptionConfiguration func(options *ChainOptions) + +// DefaultChainOptions returns the default configuration for the chains. +// These options can be configured by passing configuration functions to E2ETestSuite.GetChains. +func DefaultChainOptions() ChainOptions { + tc := FromEnv() + chainACfg := newDefaultSimappConfig(tc, "simapp-a", "chain-a", "atoma") + chainBCfg := newDefaultSimappConfig(tc, "simapp-b", "chain-b", "atomb") + return ChainOptions{ + ChainAConfig: &chainACfg, + ChainBConfig: &chainBCfg, + } +} + +// newDefaultSimappConfig creates an ibc configuration for simd. +func newDefaultSimappConfig(tc TestConfig, name, chainID, denom string) ibc.ChainConfig { + return ibc.ChainConfig{ + Type: "cosmos", + Name: name, + ChainID: chainID, + Images: []ibc.DockerImage{ + { + Repository: tc.SimdImage, + Version: tc.SimdTag, + }, + }, + Bin: "simd", + Bech32Prefix: "cosmos", + Denom: denom, + GasPrices: fmt.Sprintf("0.01%s", denom), + GasAdjustment: 1.3, + TrustingPeriod: "508h", + NoHostMount: false, + } +} diff --git a/e2e/testsuite/relayer.go b/e2e/testsuite/relayer.go new file mode 100644 index 00000000000..f71ef586ed9 --- /dev/null +++ b/e2e/testsuite/relayer.go @@ -0,0 +1,22 @@ +package testsuite + +import ( + "testing" + + dockerclient "github.com/docker/docker/client" + "github.com/strangelove-ventures/ibctest" + "github.com/strangelove-ventures/ibctest/ibc" + "github.com/strangelove-ventures/ibctest/relayer" + "go.uber.org/zap" +) + +const ( + cosmosRelayerRepository = "ghcr.io/cosmos/relayer" +) + +// newCosmosRelayer returns an instance of the go relayer. +func newCosmosRelayer(t *testing.T, logger *zap.Logger, dockerClient *dockerclient.Client, network string) ibc.Relayer { + return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage(cosmosRelayerRepository, "main")).Build( + t, dockerClient, network, + ) +} diff --git a/e2e/testsuite/testsuite.go b/e2e/testsuite/testsuite.go index 63c7cf38b88..f983d0e6d98 100644 --- a/e2e/testsuite/testsuite.go +++ b/e2e/testsuite/testsuite.go @@ -5,16 +5,16 @@ import ( "fmt" "io/ioutil" "strings" - "testing" "time" + "e2e/testconfig" + sdk "github.com/cosmos/cosmos-sdk/types" dockerclient "github.com/docker/docker/client" "github.com/strangelove-ventures/ibctest" "github.com/strangelove-ventures/ibctest/broadcast" "github.com/strangelove-ventures/ibctest/chain/cosmos" "github.com/strangelove-ventures/ibctest/ibc" - "github.com/strangelove-ventures/ibctest/relayer" "github.com/strangelove-ventures/ibctest/test" "github.com/strangelove-ventures/ibctest/testreporter" "github.com/stretchr/testify/suite" @@ -23,20 +23,21 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - "github.com/cosmos/ibc-go/v4/e2e/testconfig" feetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types" ) const ( + // ChainARelayerName is the name given to the relayer wallet on ChainA ChainARelayerName = "rlyA" + // ChainBRelayerName is the name given to the relayer wallet on ChainB ChainBRelayerName = "rlyB" ) // E2ETestSuite has methods and functionality which can be shared among all test suites. type E2ETestSuite struct { suite.Suite - clientSets map[string]GRPCClientSet - chainPairs map[string]chainPair + grpcClientSets map[string]GRPCClientSet + paths map[string]path logger *zap.Logger DockerClient *dockerclient.Client network string @@ -47,58 +48,51 @@ type GRPCClientSet struct { FeeQueryClient feetypes.QueryClient } -// chainPair is a pairing of two chains which will be used in a test. -type chainPair struct { +// path is a pairing of two chains which will be used in a test. +type path struct { chainA, chainB *cosmos.CosmosChain } -// ChainOptions stores chain configurations for the chains that will be -// created for the tests. They can be modified by passing ChainOptionConfiguration -// to E2ETestSuite.GetChains. -type ChainOptions struct { - ChainAConfig *ibc.ChainConfig - ChainBConfig *ibc.ChainConfig +// newPath returns a path built from the given chains. +func newPath(chainA, chainB *cosmos.CosmosChain) path { + return path{ + chainA: chainA, + chainB: chainB, + } } -// ChainOptionConfiguration enables arbitrary configuration of ChainOptions. -type ChainOptionConfiguration func(options *ChainOptions) +// GetRelayerUsers returns two ibctest.User instances which can be used for the relayer users +// on the two chains. +func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...testconfig.ChainOptionConfiguration) (*ibctest.User, *ibctest.User) { + chainA, chainB := s.GetChains(chainOpts...) + chainAAccountBytes, err := chainA.GetAddress(ctx, ChainARelayerName) + s.Require().NoError(err) -// GetChains returns a chain a and b that can be used in a test. The pair returned -// is unique to the current test being run. Note: this function does not create containers. -func (s *E2ETestSuite) GetChains(chainOpts ...ChainOptionConfiguration) (*cosmos.CosmosChain, *cosmos.CosmosChain) { - if s.chainPairs == nil { - s.chainPairs = map[string]chainPair{} - } - cp, ok := s.chainPairs[s.T().Name()] - if ok { - return cp.chainA, cp.chainB - } + chainBAccountBytes, err := chainB.GetAddress(ctx, ChainBRelayerName) + s.Require().NoError(err) - chainOptions := defaultChainOptions() - for _, opt := range chainOpts { - opt(&chainOptions) + chainARelayerUser := ibctest.User{ + Address: chainAAccountBytes, + KeyName: ChainARelayerName, } - chainA, chainB := s.createCosmosChains(chainOptions) - cp = chainPair{ - chainA: chainA, - chainB: chainB, + chainBRelayerUser := ibctest.User{ + Address: chainBAccountBytes, + KeyName: ChainBRelayerName, } - s.chainPairs[s.T().Name()] = cp - - return cp.chainA, cp.chainB + return &chainARelayerUser, &chainBRelayerUser } -// CreateChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel +// SetupChainsRelayerAndChannel create two chains, a relayer, establishes a connection and creates a channel // using the given channel options. The relayer returned by this function has not yet started. It should be started // with E2ETestSuite.StartRelayer if needed. // This should be called at the start of every test, unless fine grained control is required. -func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) (ibc.Relayer, ibc.ChannelOutput) { +func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts ...func(*ibc.CreateChannelOptions)) (ibc.Relayer, ibc.ChannelOutput) { chainA, chainB := s.GetChains() home, err := ioutil.TempDir("", "") s.Require().NoError(err) - r := newRelayer(s.T(), s.logger, s.DockerClient, s.network) + r := newCosmosRelayer(s.T(), s.logger, s.DockerClient, s.network) pathName := fmt.Sprintf("%s-path", s.T().Name()) pathName = strings.ReplaceAll(pathName, "/", "-") @@ -150,41 +144,57 @@ func (s *E2ETestSuite) CreateChainsRelayerAndChannel(ctx context.Context, channe return r, chainAChannels[len(chainAChannels)-1] } -func (s *E2ETestSuite) GetChainGRCPClientSet(chain ibc.Chain) GRPCClientSet { - cs, ok := s.clientSets[chain.Config().ChainID] - s.Require().True(ok, "chain %s does not have a clientset", chain.Config().ChainID) - return cs -} - -func (s *E2ETestSuite) initClientSet(chain *cosmos.CosmosChain) { - // Create a connection to the gRPC server. - grpcConn, err := grpc.Dial( - chain.GetHostGRPCAddress(), - grpc.WithTransportCredentials(insecure.NewCredentials()), - ) - s.Require().NoError(err) +// GetChains returns two chains that can be used in a test. The pair returned +// is unique to the current test being run. Note: this function does not create containers. +func (s *E2ETestSuite) GetChains(chainOpts ...testconfig.ChainOptionConfiguration) (*cosmos.CosmosChain, *cosmos.CosmosChain) { + if s.paths == nil { + s.paths = map[string]path{} + } - if s.clientSets == nil { - s.clientSets = map[string]GRPCClientSet{} + path, ok := s.paths[s.T().Name()] + if ok { + return path.chainA, path.chainB + } + chainOptions := testconfig.DefaultChainOptions() + for _, opt := range chainOpts { + opt(&chainOptions) } - s.clientSets[chain.Config().ChainID] = GRPCClientSet{ - FeeQueryClient: feetypes.NewQueryClient(grpcConn), + + chainA, chainB := s.createCosmosChains(chainOptions) + path = newPath(chainA, chainB) + s.paths[s.T().Name()] = path + + return path.chainA, path.chainB +} + +// BroadcastMessages broadcasts the provided messages to the given chain and signs them on behalf of the provided user. +// Once the broadcast response is returned, we wait for a few blocks to be created on both chain A and chain B. +func (s *E2ETestSuite) BroadcastMessages(ctx context.Context, chain *cosmos.CosmosChain, user broadcast.User, msgs ...sdk.Msg) (sdk.TxResponse, error) { + broadcaster := cosmos.NewBroadcaster(s.T(), chain) + resp, err := ibctest.BroadcastTx(ctx, broadcaster, user, msgs...) + if err != nil { + return sdk.TxResponse{}, err } + + chainA, chainB := s.GetChains() + err = test.WaitForBlocks(ctx, 2, chainA, chainB) + return resp, err } -// GetRelayerWallets returns the relayer wallets associated with the test chains. +// GetRelayerWallets returns the relayer wallets associated with the chains. func (s *E2ETestSuite) GetRelayerWallets(relayer ibc.Relayer) (ibc.RelayerWallet, ibc.RelayerWallet, error) { chainA, chainB := s.GetChains() - chainARelayWallet, ok := relayer.GetWallet(chainA.Config().ChainID) + chainARelayerWallet, ok := relayer.GetWallet(chainA.Config().ChainID) if !ok { - return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find chain-a relayer wallet") + return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find chain A relayer wallet") } - chainBRelayWallet, ok := relayer.GetWallet(chainB.Config().ChainID) + + chainBRelayerWallet, ok := relayer.GetWallet(chainB.Config().ChainID) if !ok { - return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find chain-b relayer wallet") + return ibc.RelayerWallet{}, ibc.RelayerWallet{}, fmt.Errorf("unable to find chain B relayer wallet") } - return chainARelayWallet, chainBRelayWallet, nil + return chainARelayerWallet, chainBRelayerWallet, nil } // RecoverRelayerWallets adds the corresponding relayer address to the keychain of the chain. @@ -198,62 +208,91 @@ func (s *E2ETestSuite) RecoverRelayerWallets(ctx context.Context, relayer ibc.Re chainA, chainB := s.GetChains() if err := chainA.RecoverKey(ctx, ChainARelayerName, chainARelayerWallet.Mnemonic); err != nil { - return fmt.Errorf("could not recover relayer wallet on chain-a: %s", err) + return fmt.Errorf("could not recover relayer wallet on chain A: %s", err) } if err := chainB.RecoverKey(ctx, ChainBRelayerName, chainBRelayerWallet.Mnemonic); err != nil { - return fmt.Errorf("could not recover relayer wallet on chain-b: %s", err) + return fmt.Errorf("could not recover relayer wallet on chain B: %s", err) } return nil } -// BroadcastMessages broadcasts the provided messages to the given chain and signs them on behalf of the provided user. -func (s *E2ETestSuite) BroadcastMessages(ctx context.Context, chain *cosmos.CosmosChain, user broadcast.User, msgs ...sdk.Msg) (sdk.TxResponse, error) { - broadcaster := cosmos.NewBroadcaster(s.T(), chain) - resp, err := ibctest.BroadcastTx(ctx, broadcaster, user, msgs...) - if err != nil { - return sdk.TxResponse{}, err - } - - chainA, chainB := s.GetChains() - err = test.WaitForBlocks(ctx, 2, chainA, chainB) - return resp, err -} - // StartRelayer starts the given relayer. func (s *E2ETestSuite) StartRelayer(relayer ibc.Relayer) { if s.startRelayerFn == nil { panic("cannot start relayer before it is created!") } + s.startRelayerFn(relayer) } -// CreateUserOnChainA creates a user with the given amount of funds on chain-a. +// CreateUserOnChainA creates a user with the given amount of funds on chain A. func (s *E2ETestSuite) CreateUserOnChainA(ctx context.Context, amount int64) *ibctest.User { chainA, _ := s.GetChains() return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, chainA)[0] } -// CreateUserOnChainB creates a user with the given amount of funds on chain-b. +// CreateUserOnChainB creates a user with the given amount of funds on chain B. func (s *E2ETestSuite) CreateUserOnChainB(ctx context.Context, amount int64) *ibctest.User { _, chainB := s.GetChains() return ibctest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), amount, chainB)[0] } -// GetChainANativeBalance gets the balance of a given user on chain-a. +// GetChainANativeBalance gets the balance of a given user on chain A. func (s *E2ETestSuite) GetChainANativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { chainA, _ := s.GetChains() return GetNativeChainBalance(ctx, chainA, user) } -// GetChainBNativeBalance gets the balance of a given user on chain-b. +// GetChainBNativeBalance gets the balance of a given user on chain B. func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user *ibctest.User) (int64, error) { _, chainB := s.GetChains() return GetNativeChainBalance(ctx, chainB, user) } +// GetChainGRCPClientSet gets the GRPC clientset associated with the given chain. +func (s *E2ETestSuite) GetChainGRCPClientSet(chain ibc.Chain) GRPCClientSet { + cs, ok := s.grpcClientSets[chain.Config().ChainID] + s.Require().True(ok, "chain %s does not have a GRPC clientset", chain.Config().ChainID) + return cs +} + +// initClientSet establishes GRPC clients with the given chain. +// The created GRPCClientSet can be retreived with GetChainGRCPClientSet. +func (s *E2ETestSuite) initClientSet(chain *cosmos.CosmosChain) { + // Create a connection to the gRPC server. + grpcConn, err := grpc.Dial( + chain.GetHostGRPCAddress(), + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) + s.Require().NoError(err) + s.T().Cleanup(func() { + if err := grpcConn.Close(); err != nil { + s.T().Logf("failed closing GRPC connection to chain %s: %s", chain.Config().ChainID, err) + } + }) + + if s.grpcClientSets == nil { + s.grpcClientSets = map[string]GRPCClientSet{} + } + + s.grpcClientSets[chain.Config().ChainID] = GRPCClientSet{ + FeeQueryClient: feetypes.NewQueryClient(grpcConn), + } +} + +// AssertValidTxResponse verifies that an sdk.TxResponse +// has non-empty values. +func (s *E2ETestSuite) AssertValidTxResponse(resp sdk.TxResponse) { + respLogsMsg := resp.Logs.String() + s.Require().NotEqual(int64(0), resp.GasUsed, respLogsMsg) + s.Require().NotEqual(int64(0), resp.GasWanted, respLogsMsg) + s.Require().NotEmpty(resp.Events, respLogsMsg) + s.Require().NotEmpty(resp.Data, respLogsMsg) +} + // createCosmosChains creates two separate chains in docker containers. // test and can be retrieved with GetChains. -func (s *E2ETestSuite) createCosmosChains(chainOptions ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { +func (s *E2ETestSuite) createCosmosChains(chainOptions testconfig.ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) { ctx := context.Background() client, network := ibctest.DockerSetup(s.T()) @@ -280,43 +319,6 @@ func (s *E2ETestSuite) createCosmosChains(chainOptions ChainOptions) (*cosmos.Co return chainA, chainB } -func (s *E2ETestSuite) GetChannel(ctx context.Context, chain ibc.Chain, r ibc.Relayer) ibc.ChannelOutput { - eRep := s.getRelayerExecReporter() - channels, err := r.GetChannels(ctx, eRep, chain.Config().ChainID) - s.Require().NoError(err) - return channels[len(channels)-1] -} - -// GetRelayerUsers returns two ibctest.User instances which can be used for the relayer users -// on the two chains. -func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...ChainOptionConfiguration) (*ibctest.User, *ibctest.User) { - chainA, chainB := s.GetChains(chainOpts...) - chainAAccountBytes, err := chainA.GetAddress(ctx, ChainARelayerName) - s.Require().NoError(err) - - chainBAccountBytes, err := chainB.GetAddress(ctx, ChainBRelayerName) - s.Require().NoError(err) - - chainARelayerUser := ibctest.User{ - Address: chainAAccountBytes, - KeyName: ChainARelayerName, - } - - chainBRelayerUser := ibctest.User{ - Address: chainBAccountBytes, - KeyName: ChainBRelayerName, - } - return &chainARelayerUser, &chainBRelayerUser -} - -func (s *E2ETestSuite) AssertValidTxResponse(resp sdk.TxResponse) { - respLogsMsg := resp.Logs.String() - s.Require().NotEqual(int64(0), resp.GasUsed, respLogsMsg) - s.Require().NotEqual(int64(0), resp.GasWanted, respLogsMsg) - s.Require().NotEmpty(resp.Events, respLogsMsg) - s.Require().NotEmpty(resp.Data, respLogsMsg) -} - // getRelayerExecReporter returns a testreporter.RelayerExecReporter instances // using the current test's testing.T. func (s *E2ETestSuite) getRelayerExecReporter() *testreporter.RelayerExecReporter { @@ -332,44 +334,3 @@ func GetNativeChainBalance(ctx context.Context, chain ibc.Chain, user *ibctest.U } return bal, nil } - -// defaultChainOptions returns the default configuration for the chains. -// These options can be configured by passing configuration functions to E2ETestSuite.GetChains. -func defaultChainOptions() ChainOptions { - tc := testconfig.FromEnv() - chainACfg := newDefaultSimappConfig(tc, "simapp-a", "chain-a", "atoma") - chainBCfg := newDefaultSimappConfig(tc, "simapp-b", "chain-b", "atomb") - return ChainOptions{ - ChainAConfig: &chainACfg, - ChainBConfig: &chainBCfg, - } -} - -// newRelayer returns an instance of the go relayer. -func newRelayer(t *testing.T, logger *zap.Logger, client *dockerclient.Client, network string) ibc.Relayer { - return ibctest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, relayer.CustomDockerImage("ghcr.io/cosmos/relayer", "main")).Build( - t, client, network, - ) -} - -// newDefaultSimappConfig creates an ibc configuration for simd. -func newDefaultSimappConfig(tc testconfig.TestConfig, name, chainId, denom string) ibc.ChainConfig { - return ibc.ChainConfig{ - Type: "cosmos", - Name: name, - ChainID: chainId, - Images: []ibc.DockerImage{ - { - Repository: tc.SimdImage, - Version: tc.SimdTag, - }, - }, - Bin: "simd", - Bech32Prefix: "cosmos", - Denom: denom, - GasPrices: fmt.Sprintf("0.01%s", denom), - GasAdjustment: 1.3, - TrustingPeriod: "508h", - NoHostMount: false, - } -}