From a92d20639d6f88fbdb1c8016abdd946665d02f60 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Thu, 8 Feb 2024 11:30:50 +0100 Subject: [PATCH] chore: refactor Hermes relayers setups and executions in the E2E tests (#2859) * refactor hermes setup in e2e tests * chore: appease linter --------- Co-authored-by: MSalopek --- tests/e2e/e2e_bypassminfee_test.go | 16 ++- tests/e2e/e2e_exec_test.go | 36 +++-- tests/e2e/e2e_ibc_test.go | 144 +++++++------------ tests/e2e/e2e_setup_test.go | 186 ++++++------------------- tests/e2e/e2e_test.go | 5 +- tests/e2e/scripts/hermes1_bootstrap.sh | 152 -------------------- tests/e2e/scripts/hermes_bootstrap.sh | 80 ++++++++++- 7 files changed, 197 insertions(+), 422 deletions(-) delete mode 100755 tests/e2e/scripts/hermes1_bootstrap.sh diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 8652cdf0c2c..7d1c5c235db 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -116,8 +116,6 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), }, proposalCounter, submitter, standardFees.String()) - // use hermes1 to test default ibc bypass-msg - // // test 1: transaction only contains bypass-msgs, pass s.testTxContainsOnlyIBCBypassMsg() // test 2: test transactions contains both bypass and non-bypass msgs (sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}) @@ -145,7 +143,7 @@ func (s *IntegrationTestSuite) testTxContainsOnlyIBCBypassMsg() { pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) - pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist := s.hermesPendingPackets(s.chainA.id, transferChannel) s.Require().False(pendingPacketsExist) // confirm relayer wallets do not pay fees @@ -161,12 +159,18 @@ func (s *IntegrationTestSuite) testTxContainsMixBypassNonBypassMsg() { s.Require().True(ok) // make sure that the transaction is timeout time.Sleep(3 * time.Second) - pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist := s.hermesPendingPackets(s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) + // attempt to relay packets without paying fees pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pass) - // clear packets with paying fee, to not influence the next transaction + + // assert that packets were not relayed + pendingPacketsExist = s.hermesPendingPackets(s.chainA.id, transferChannel) + s.Require().True(pendingPacketsExist) + + // clear packets with paying fees pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) } @@ -178,7 +182,7 @@ func (s *IntegrationTestSuite) testBypassMsgsExceedMaxBypassGasLimit() { pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pass) - pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist := s.hermesPendingPackets(s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 85ac056959e..70d772e636b 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -1,6 +1,7 @@ package e2e import ( + "bufio" "bytes" "context" "encoding/json" @@ -712,16 +713,13 @@ func (s *IntegrationTestSuite) executeGaiaTxCommand(ctx context.Context, c *chai } } -func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesCmd []string) ([]byte, []byte) { - var ( - outBuf bytes.Buffer - errBuf bytes.Buffer - ) +func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesCmd []string) ([]byte, error) { + var outBuf bytes.Buffer exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ Context: ctx, AttachStdout: true, AttachStderr: true, - Container: s.hermesResource1.Container.ID, + Container: s.hermesResource.Container.ID, User: "root", Cmd: hermesCmd, }) @@ -731,14 +729,32 @@ func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesC Context: ctx, Detach: false, OutputStream: &outBuf, - ErrorStream: &errBuf, }) s.Require().NoError(err) - stdOut := outBuf.Bytes() - stdErr := errBuf.Bytes() + // Check that the stdout output contains the expected status + // and look for errors, e.g "insufficient fees" + stdOut := []byte{} + scanner := bufio.NewScanner(&outBuf) + for scanner.Scan() { + stdOut = scanner.Bytes() + var out map[string]interface{} + err = json.Unmarshal(stdOut, &out) + s.Require().NoError(err) + if err != nil { + return nil, fmt.Errorf("hermes relayer command returned failed with error: %s", err) + } + // errors are catched by observing the logs level in the stderr output + if lvl := out["level"]; lvl != nil && strings.ToLower(lvl.(string)) == "error" { + errMsg := out["fields"].(map[string]interface{})["message"] + return nil, fmt.Errorf("hermes relayer command failed: %s", errMsg) + } + if s := out["status"]; s != nil && s != "success" { + return nil, fmt.Errorf("hermes relayer command returned failed with status: %s", s) + } + } - return stdOut, stdErr + return stdOut, nil } func (s *IntegrationTestSuite) expectErrExecValidation(chain *chain, valIdx int, expectErr bool) func([]byte, []byte) bool { diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 8ac4c31899f..f84412eff39 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -1,8 +1,6 @@ package e2e import ( - "bufio" - "bytes" "context" "encoding/json" "fmt" @@ -10,8 +8,6 @@ import ( "strings" "time" - "github.com/ory/dockertest/v3/docker" - "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -65,6 +61,7 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID hermesCmd := []string{ hermesBinary, + "--json", fmt.Sprintf("--config=%s", configPath), "tx", "ft-transfer", @@ -78,8 +75,7 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID fmt.Sprintf("--number-msgs=%v", numMsg), } - stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) - if strings.Contains(string(stdout), "ERROR") || strings.Contains(string(stderr), "ERROR") { + if _, err := s.executeHermesCommand(ctx, hermesCmd); err != nil { return false } @@ -92,6 +88,7 @@ func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID hermesCmd := []string{ hermesBinary, + "--json", fmt.Sprintf("--config=%s", configPath), "clear", "packets", @@ -100,9 +97,7 @@ func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID fmt.Sprintf("--port=%s", "transfer"), } - stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) - - if strings.Contains(string(stdout), "ERROR") || strings.Contains(string(stderr), "ERROR") { + if _, err := s.executeHermesCommand(ctx, hermesCmd); err != nil { return false } @@ -121,13 +116,12 @@ type RelayerPacketsOutput struct { Status string `json:"status"` } -func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) (pendingPackets bool) { +func (s *IntegrationTestSuite) hermesPendingPackets(chainID, channelID string) (pendingPackets bool) { //nolint:unparam ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() hermesCmd := []string{ hermesBinary, "--json", - fmt.Sprintf("--config=%s", configPath), "query", "packet", "pending", @@ -136,18 +130,12 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel fmt.Sprintf("--port=%s", "transfer"), } - stdout, _ := s.executeHermesCommand(ctx, hermesCmd) - reader := bytes.NewReader(stdout) - sc := bufio.NewScanner(reader) + stdout, err := s.executeHermesCommand(ctx, hermesCmd) + s.Require().NoError(err) var relayerPacketsOutput RelayerPacketsOutput - - // TODO: check why no error is never returned - // works atm because the last line of stdout is always the query output - for sc.Scan() { - sc.Bytes() - _ = json.Unmarshal(sc.Bytes(), &relayerPacketsOutput) - } + err = json.Unmarshal(stdout, &relayerPacketsOutput) + s.Require().NoError(err) // Check if "unreceived_packets" exists in "src" return len(relayerPacketsOutput.Result.Src.UnreceivedPackets) != 0 @@ -155,7 +143,7 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) - acctAddrChainA, _ := s.chainA.genesisAccounts[relayerAccountIndexHermes1].keyInfo.GetAddress() + acctAddrChainA, _ := s.chainA.genesisAccounts[relayerAccountIndexHermes].keyInfo.GetAddress() scrRelayerBalance, err := getSpecificBalance( chainAAPIEndpoint, acctAddrChainA.String(), @@ -163,7 +151,7 @@ func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin s.Require().NoError(err) chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp")) - acctAddrChainB, _ := s.chainB.genesisAccounts[relayerAccountIndexHermes1].keyInfo.GetAddress() + acctAddrChainB, _ := s.chainB.genesisAccounts[relayerAccountIndexHermes].keyInfo.GetAddress() dstRelayerBalance, err := getSpecificBalance( chainBAPIEndpoint, acctAddrChainB.String(), @@ -179,90 +167,45 @@ func (s *IntegrationTestSuite) createConnection() { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() - exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ - Context: ctx, - AttachStdout: true, - AttachStderr: true, - Container: s.hermesResource0.Container.ID, - User: "root", - Cmd: []string{ - "hermes", - "create", - "connection", - "--a-chain", - s.chainA.id, - "--b-chain", - s.chainB.id, - }, - }) - s.Require().NoError(err) - - var ( - outBuf bytes.Buffer - errBuf bytes.Buffer - ) + hermesCmd := []string{ + hermesBinary, + "--json", + "create", + "connection", + "--a-chain", + s.chainA.id, + "--b-chain", + s.chainB.id, + } - err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ - Context: ctx, - Detach: false, - OutputStream: &outBuf, - ErrorStream: &errBuf, - }) - s.Require().NoErrorf( - err, - "failed connect chains; stdout: %s, stderr: %s", outBuf.String(), errBuf.String(), - ) + _, err := s.executeHermesCommand(ctx, hermesCmd) + s.Require().NoError(err, "failed to connect chains: %s", err) s.T().Logf("connected %s and %s chains via IBC", s.chainA.id, s.chainB.id) } func (s *IntegrationTestSuite) createChannel() { - s.T().Logf("connecting %s and %s chains via IBC", s.chainA.id, s.chainB.id) + s.T().Logf("creating IBC transfer channel created between chains %s and %s", s.chainA.id, s.chainB.id) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() + hermesCmd := []string{ + hermesBinary, + "--json", + "create", + "channel", + "--a-chain", s.chainA.id, + "--a-connection", "connection-0", + "--a-port", "transfer", + "--b-port", "transfer", + "--channel-version", "ics20-1", + "--order", "unordered", + } - exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ - Context: ctx, - AttachStdout: true, - AttachStderr: true, - Container: s.hermesResource0.Container.ID, - User: "root", - Cmd: []string{ - "hermes", - txCommand, - "chan-open-init", - "--dst-chain", - s.chainA.id, - "--src-chain", - s.chainB.id, - "--dst-connection", - "connection-0", - "--src-port=transfer", - "--dst-port=transfer", - }, - }) - - s.Require().NoError(err) - - var ( - outBuf bytes.Buffer - errBuf bytes.Buffer - ) - - err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ - Context: ctx, - Detach: false, - OutputStream: &outBuf, - ErrorStream: &errBuf, - }) - - s.Require().NoErrorf( - err, - "failed connect chains; stdout: %s, stderr: %s", outBuf.String(), errBuf.String(), - ) + _, err := s.executeHermesCommand(ctx, hermesCmd) + s.Require().NoError(err, "failed to create IBC transfer channel between chains: %s", err) - s.T().Logf("connected %s and %s chains via IBC", s.chainA.id, s.chainB.id) + s.T().Logf("IBC transfer channel created between chains %s and %s", s.chainA.id, s.chainB.id) } func (s *IntegrationTestSuite) testIBCTokenTransfer() { @@ -302,6 +245,9 @@ func (s *IntegrationTestSuite) testIBCTokenTransfer() { tokenAmt := 3300000000 s.sendIBC(s.chainA, 0, sender, recipient, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), "") + pass := s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + s.Require().Eventually( func() bool { balances, err = queryGaiaAllBalances(chainBAPIEndpoint, recipient) @@ -392,6 +338,9 @@ func (s *IntegrationTestSuite) testMultihopIBCTokenTransfer() { s.sendIBC(s.chainA, 0, sender, middlehop, strconv.Itoa(tokenAmt)+uatomDenom, standardFees.String(), string(memo)) + pass := s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + s.Require().Eventually( func() bool { afterSenderUAtomBalance, err := getSpecificBalance(chainAAPIEndpoint, sender, uatomDenom) @@ -478,6 +427,9 @@ func (s *IntegrationTestSuite) testFailedMultihopIBCTokenTransfer() { 1*time.Second, ) + pass := s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + // since the forward receiving account is invalid, it should be refunded to the original sender (minus the original fee) s.Require().Eventually( func() bool { diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index f41561b9649..a5f36f4e085 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -4,9 +4,7 @@ import ( "context" "encoding/json" "fmt" - "io" "math/rand" - "net/http" "os" "os/exec" "path" @@ -56,19 +54,17 @@ const ( stakeDenom = "stake" initBalanceStr = "110000000000stake,100000000000000000photon,100000000000000000uatom" minGasPrice = "0.00001" - // // the test globalfee in genesis is the same as minGasPrice - // // global fee lower/higher than min_gas_price - initialGlobalFeeAmt = "0.00001" - lowGlobalFeesAmt = "0.000001" - highGlobalFeeAmt = "0.0001" - maxTotalBypassMinFeeMsgGasUsage = "1" - gas = 200000 - - govProposalBlockBuffer = 35 - relayerAccountIndexHermes0 = 0 - relayerAccountIndexHermes1 = 1 - numberOfEvidences = 10 - slashingShares int64 = 10000 + // the test globalfee in genesis is the same as minGasPrice + // global fee lower/higher than min_gas_price + initialGlobalFeeAmt = "0.00001" + lowGlobalFeesAmt = "0.000001" + highGlobalFeeAmt = "0.0001" + maxTotalBypassMinFeeMsgGasUsage = "1" + gas = 200000 + govProposalBlockBuffer = 35 + relayerAccountIndexHermes = 0 + numberOfEvidences = 10 + slashingShares int64 = 10000 proposalGlobalFeeFilename = "proposal_globalfee.json" proposalBypassMsgFilename = "proposal_bypass_msg.json" @@ -86,28 +82,26 @@ const ( ) var ( - gaiaConfigPath = filepath.Join(gaiaHomePath, "config") - stakingAmount = sdk.NewInt(100000000000) - stakingAmountCoin = sdk.NewCoin(uatomDenom, stakingAmount) - tokenAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(3300000000)) // 3,300uatom - standardFees = sdk.NewCoin(uatomDenom, sdk.NewInt(330000)) // 0.33uatom - depositAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(330000000)) // 3,300uatom - distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() - govModuleAddress = authtypes.NewModuleAddress(govtypes.ModuleName).String() - proposalCounter = 0 - HermesResource0Purged = false + gaiaConfigPath = filepath.Join(gaiaHomePath, "config") + stakingAmount = sdk.NewInt(100000000000) + stakingAmountCoin = sdk.NewCoin(uatomDenom, stakingAmount) + tokenAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(3300000000)) // 3,300uatom + standardFees = sdk.NewCoin(uatomDenom, sdk.NewInt(330000)) // 0.33uatom + depositAmount = sdk.NewCoin(uatomDenom, sdk.NewInt(330000000)) // 3,300uatom + distModuleAddress = authtypes.NewModuleAddress(distrtypes.ModuleName).String() + govModuleAddress = authtypes.NewModuleAddress(govtypes.ModuleName).String() + proposalCounter = 0 ) type IntegrationTestSuite struct { suite.Suite - tmpDirs []string - chainA *chain - chainB *chain - dkrPool *dockertest.Pool - dkrNet *dockertest.Network - hermesResource0 *dockertest.Resource - hermesResource1 *dockertest.Resource + tmpDirs []string + chainA *chain + chainB *chain + dkrPool *dockertest.Pool + dkrNet *dockertest.Network + hermesResource *dockertest.Resource valResources map[string][]*dockertest.Resource } @@ -167,8 +161,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.runValidators(s.chainB, 10) time.Sleep(10 * time.Second) - s.runIBCRelayer0() - s.runIBCRelayer1() + s.runIBCRelayer() } func (s *IntegrationTestSuite) TearDownSuite() { @@ -183,13 +176,7 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.T().Log("tearing down e2e integration test suite...") - s.Require().NoError(s.dkrPool.Purge(s.hermesResource1)) - // if runIBCTest, s.hermesResource0 already purged in TestIBC() - // in GovSoftwareUpgrade test, s.TearDownSuite() then s.SetupSuite() - // if IBCTest runs before GovSoftwareUpgrade, s.hermesResource0 is already purged. - if !HermesResource0Purged { - s.Require().NoError(s.dkrPool.Purge(s.hermesResource0)) - } + s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) for _, vr := range s.valResources { for _, r := range vr { @@ -210,11 +197,10 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) initNodes(c *chain) { s.Require().NoError(c.createAndInitValidators(2)) /* Adding 4 accounts to val0 local directory - c.genesisAccounts[0]: Relayer0 Wallet + c.genesisAccounts[0]: Relayer Account c.genesisAccounts[1]: ICA Owner c.genesisAccounts[2]: Test Account 1 c.genesisAccounts[3]: Test Account 2 - c.genesisAccounts[4]: Relayer1 Wallet */ s.Require().NoError(c.addAccountFromMnemonic(5)) // Initialize a genesis file for the first validator @@ -616,9 +602,10 @@ func noRestart(config *docker.HostConfig) { } } -// hermes0 is for ibc and packet-forward-middleware(PFM) test, hermes0 is keep running during the ibc and PFM test. -func (s *IntegrationTestSuite) runIBCRelayer0() { - s.T().Log("starting Hermes relayer container 0...") +// runIBCRelayer bootstraps an IBC Hermes relayer by creating an IBC connection and +// a transfer channel between chainA and chainB. +func (s *IntegrationTestSuite) runIBCRelayer() { + s.T().Log("starting Hermes relayer container") tmpDir, err := os.MkdirTemp("", "gaia-e2e-testnet-hermes-") s.Require().NoError(err) @@ -627,8 +614,8 @@ func (s *IntegrationTestSuite) runIBCRelayer0() { gaiaAVal := s.chainA.validators[0] gaiaBVal := s.chainB.validators[0] - gaiaARly := s.chainA.genesisAccounts[relayerAccountIndexHermes0] - gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndexHermes0] + gaiaARly := s.chainA.genesisAccounts[relayerAccountIndexHermes] + gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndexHermes] hermesCfgPath := path.Join(tmpDir, "hermes") @@ -639,9 +626,9 @@ func (s *IntegrationTestSuite) runIBCRelayer0() { ) s.Require().NoError(err) - s.hermesResource0, err = s.dkrPool.RunWithOptions( + s.hermesResource, err = s.dkrPool.RunWithOptions( &dockertest.RunOptions{ - Name: fmt.Sprintf("%s-%s-relayer-0", s.chainA.id, s.chainB.id), + Name: fmt.Sprintf("%s-%s-relayer", s.chainA.id, s.chainB.id), Repository: "ghcr.io/cosmos/hermes-e2e", Tag: "1.0.0", NetworkID: s.dkrNet.Network.ID, @@ -665,43 +652,14 @@ func (s *IntegrationTestSuite) runIBCRelayer0() { Entrypoint: []string{ "sh", "-c", - "chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh", + "chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh && tail -f /dev/null", }, }, noRestart, ) s.Require().NoError(err) - endpoint := fmt.Sprintf("http://%s/state", s.hermesResource0.GetHostPort("3031/tcp")) - s.Require().Eventually( - func() bool { - resp, err := http.Get(endpoint) //nolint:gosec // this is a test - if err != nil { - return false - } - - defer resp.Body.Close() - - bz, err := io.ReadAll(resp.Body) - if err != nil { - return false - } - - var respBody map[string]interface{} - if err := json.Unmarshal(bz, &respBody); err != nil { - return false - } - - status := respBody["status"].(string) - result := respBody["result"].(map[string]interface{}) - - return status == "success" && len(result["chains"].([]interface{})) == 2 - }, - 5*time.Minute, - time.Second, - "hermes relayer not healthy", - ) - s.T().Logf("started Hermes relayer 0 container: %s", s.hermesResource0.Container.ID) + s.T().Logf("started Hermes relayer container: %s", s.hermesResource.Container.ID) // XXX: Give time to both networks to start, otherwise we might see gRPC // transport errors. @@ -709,75 +667,9 @@ func (s *IntegrationTestSuite) runIBCRelayer0() { // create the client, connection and channel between the two Gaia chains s.createConnection() - time.Sleep(10 * time.Second) s.createChannel() } -// hermes1 is for bypass-msg test. Hermes1 is to process asynchronous transactions, -// Hermes1 has access to two Hermes configurations: one configuration allows paying fees, while the other does not. -// With Hermes1, better control can be achieved regarding whether fees are paid when clearing transactions. -func (s *IntegrationTestSuite) runIBCRelayer1() { - s.T().Log("starting Hermes relayer container 1...") - - tmpDir, err := os.MkdirTemp("", "gaia-e2e-testnet-hermes-") - s.Require().NoError(err) - s.tmpDirs = append(s.tmpDirs, tmpDir) - - gaiaAVal := s.chainA.validators[0] - gaiaBVal := s.chainB.validators[0] - - gaiaARly := s.chainA.genesisAccounts[relayerAccountIndexHermes1] - gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndexHermes1] - - hermesCfgPath := path.Join(tmpDir, "hermes") - - s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755)) - _, err = copyFile( - filepath.Join("./scripts/", "hermes1_bootstrap.sh"), - filepath.Join(hermesCfgPath, "hermes1_bootstrap.sh"), - ) - s.Require().NoError(err) - - s.hermesResource1, err = s.dkrPool.RunWithOptions( - &dockertest.RunOptions{ - Name: fmt.Sprintf("%s-%s-relayer-1", s.chainA.id, s.chainB.id), - Repository: "ghcr.io/cosmos/hermes-e2e", - Tag: "1.0.0", - NetworkID: s.dkrNet.Network.ID, - Mounts: []string{ - fmt.Sprintf("%s/:/root/hermes", hermesCfgPath), - }, - PortBindings: map[docker.Port][]docker.PortBinding{ - "3032/tcp": {{HostIP: "", HostPort: "3032"}}, - }, - Env: []string{ - fmt.Sprintf("GAIA_A_E2E_CHAIN_ID=%s", s.chainA.id), - fmt.Sprintf("GAIA_B_E2E_CHAIN_ID=%s", s.chainB.id), - fmt.Sprintf("GAIA_A_E2E_VAL_MNEMONIC=%s", gaiaAVal.mnemonic), - fmt.Sprintf("GAIA_B_E2E_VAL_MNEMONIC=%s", gaiaBVal.mnemonic), - fmt.Sprintf("GAIA_A_E2E_RLY_MNEMONIC=%s", gaiaARly.mnemonic), - fmt.Sprintf("GAIA_B_E2E_RLY_MNEMONIC=%s", gaiaBRly.mnemonic), - fmt.Sprintf("GAIA_A_E2E_VAL_HOST=%s", s.valResources[s.chainA.id][0].Container.Name[1:]), - fmt.Sprintf("GAIA_B_E2E_VAL_HOST=%s", s.valResources[s.chainB.id][0].Container.Name[1:]), - }, - User: "root", - Entrypoint: []string{ - "sh", - "-c", - "chmod +x /root/hermes/hermes1_bootstrap.sh && /root/hermes/hermes1_bootstrap.sh && tail -f /dev/null", - }, - }, - noRestart, - ) - s.Require().NoError(err) - - s.T().Logf("started Hermes relayer 1 container: %s", s.hermesResource1.Container.ID) - - // XXX: Give time to both networks to start, otherwise we might see gRPC - // transport errors. - time.Sleep(10 * time.Second) -} - func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, coins sdk.DecCoins) { type ParamInfo struct { Subspace string `json:"subspace"` diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 92e04590238..ea25c73a9cf 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -84,13 +84,10 @@ func (s *IntegrationTestSuite) TestIBC() { if !runIBCTest { s.T().Skip() } + s.testIBCTokenTransfer() s.testMultihopIBCTokenTransfer() s.testFailedMultihopIBCTokenTransfer() - - // stop hermes0 to prevent hermes0 relaying transactions - s.Require().NoError(s.dkrPool.Purge(s.hermesResource0)) - HermesResource0Purged = true s.testIBCBypassMsg() } diff --git a/tests/e2e/scripts/hermes1_bootstrap.sh b/tests/e2e/scripts/hermes1_bootstrap.sh deleted file mode 100755 index 8d572e0a2d3..00000000000 --- a/tests/e2e/scripts/hermes1_bootstrap.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/bash - -set -ex - -# initialize Hermes relayer configuration -mkdir -p /root/.hermes/ -touch /root/.hermes/config.toml - -echo $GAIA_B_E2E_RLY_MNEMONIC > /root/.hermes/GAIA_B_E2E_RLY_MNEMONIC.txt -echo $GAIA_A_E2E_RLY_MNEMONIC > /root/.hermes/GAIA_A_E2E_RLY_MNEMONIC.txt - -# setup Hermes relayer configuration with non-zero gas_price -tee /root/.hermes/config.toml < /root/.hermes/GAIA_B_E2E_RLY_MNEMONIC.txt echo $GAIA_A_E2E_RLY_MNEMONIC > /root/.hermes/GAIA_A_E2E_RLY_MNEMONIC.txt -# setup Hermes relayer configuration +# setup Hermes relayer configuration with non-zero gas_price tee /root/.hermes/config.toml <