From 62e9bec712d708340601ec90258ec38240fdf0cd Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 25 May 2023 13:11:03 +0200 Subject: [PATCH 01/22] test: setup a new hermes instance --- tests/e2e/e2e_setup_test.go | 198 +++++++++++++++++++++++++++++++++--- 1 file changed, 186 insertions(+), 12 deletions(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index b7b46e86ec0..bcdbc1be86a 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -4,8 +4,11 @@ import ( "context" "encoding/json" "fmt" + "io" + "net/http" "os" "os/exec" + "path" "path/filepath" "strconv" "strings" @@ -58,7 +61,8 @@ const ( maxTotalBypassMinFeeMsgGasUsage = "1" gas = 200000 govProposalBlockBuffer = 35 - relayerAccountIndex = 0 + relayerAccountIndexHermes0 = 0 + relayerAccountIndexHermes1 = 1 numberOfEvidences = 10 slashingShares int64 = 10000 @@ -68,6 +72,11 @@ const ( proposalCommunitySpendFilename = "proposal_community_spend.json" proposalAddConsumerChainFilename = "proposal_add_consumer.json" proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" + + hermesBinary = "hermes" + hermesCofigWithGasPrices = "/root/.hermes/config.toml" + hermesCofigNoGasPrices = "/root/.hermes/config-zero.toml" + transferChannel = "channel-0" ) var ( @@ -84,13 +93,15 @@ var ( type IntegrationTestSuite struct { suite.Suite - tmpDirs []string - chainA *chain - chainB *chain - dkrPool *dockertest.Pool - dkrNet *dockertest.Network - hermesResource *dockertest.Resource - valResources map[string][]*dockertest.Resource + tmpDirs []string + chainA *chain + chainB *chain + dkrPool *dockertest.Pool + dkrNet *dockertest.Network + hermesResource0 *dockertest.Resource + hermesResource1 *dockertest.Resource + + valResources map[string][]*dockertest.Resource } type AddressResponse struct { @@ -148,7 +159,9 @@ func (s *IntegrationTestSuite) SetupSuite() { s.runValidators(s.chainB, 10) time.Sleep(10 * time.Second) - s.runIBCRelayer() + s.runIBCRelayer0() + s.runIBCRelayer1() + } func (s *IntegrationTestSuite) TearDownSuite() { @@ -164,7 +177,8 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.T().Log("tearing down e2e integration test suite...") if runIBCTest { - s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) + // s.hermesResource0 already purged in TestIBC() + s.Require().NoError(s.dkrPool.Purge(s.hermesResource1)) } for _, vr := range s.valResources { @@ -186,12 +200,13 @@ 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]: Relayer Wallet + c.genesisAccounts[0]: Relayer0 Wallet 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(4)) + s.Require().NoError(c.addAccountFromMnemonic(5)) // Initialize a genesis file for the first validator val0ConfigDir := c.validators[0].configDir() var addrAll []sdk.AccAddress @@ -583,6 +598,165 @@ func noRestart(config *docker.HostConfig) { } } +// hermes0 is for ibc and packet-forward-middleware test +func (s *IntegrationTestSuite) runIBCRelayer0() { + s.T().Log("starting Hermes relayer container 0...") + + 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[relayerAccountIndexHermes0] + gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndexHermes0] + + hermesCfgPath := path.Join(tmpDir, "hermes") + + s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755)) + _, err = copyFile( + filepath.Join("./scripts/", "hermes_bootstrap.sh"), + filepath.Join(hermesCfgPath, "hermes_bootstrap.sh"), + ) + s.Require().NoError(err) + + s.hermesResource0, err = s.dkrPool.RunWithOptions( + &dockertest.RunOptions{ + Name: fmt.Sprintf("%s-%s-relayer-0", 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{ + "3031/tcp": {{HostIP: "", HostPort: "3031"}}, + }, + 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:]), + }, + Entrypoint: []string{ + "sh", + "-c", + "chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh", + }, + }, + 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) + + // XXX: Give time to both networks to start, otherwise we might see gRPC + // transport errors. + time.Sleep(10 * time.Second) + + // 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 +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:]), + }, + 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"` From 35d842fa4d5d648b6427512639fc95d467c6f074 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 25 May 2023 13:12:08 +0200 Subject: [PATCH 02/22] test: add executeHermesCommand --- tests/e2e/e2e_exec_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 6b007ef7c0b..4f16db42d88 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -617,6 +617,35 @@ func (s *IntegrationTestSuite) executeGaiaTxCommand(ctx context.Context, c *chai } } +func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesCmd []string) (string, string) { + var ( + outBuf bytes.Buffer + errBuf bytes.Buffer + ) + exec, err := s.dkrPool.Client.CreateExec(docker.CreateExecOptions{ + Context: ctx, + AttachStdout: true, + AttachStderr: true, + Container: s.hermesResource1.Container.ID, + User: "root", + Cmd: hermesCmd, + }) + s.Require().NoError(err) + + err = s.dkrPool.Client.StartExec(exec.ID, docker.StartExecOptions{ + Context: ctx, + Detach: false, + OutputStream: &outBuf, + ErrorStream: &errBuf, + }) + s.Require().NoError(err) + + stdOut := outBuf.Bytes() + stdErr := errBuf.Bytes() + + return string(stdOut), string(stdErr) +} + func (s *IntegrationTestSuite) expectErrExecValidation(chain *chain, valIdx int, expectErr bool) func([]byte, []byte) bool { return func(stdOut []byte, stdErr []byte) bool { var txResp sdk.TxResponse From aaed10844ad438a831faf49b0abc38d709b2d4eb Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 25 May 2023 13:12:49 +0200 Subject: [PATCH 03/22] test: add hermesTransfer --- tests/e2e/e2e_ibc_test.go | 201 ++++++++++++++++++-------------------- 1 file changed, 96 insertions(+), 105 deletions(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 4c9d3c7454a..4e629d370ef 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -5,18 +5,12 @@ import ( "context" "encoding/json" "fmt" - "io" - "net/http" - "os" - "path" - "path/filepath" "strconv" "strings" "time" "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ory/dockertest/v3" "github.com/ory/dockertest/v3/docker" ) @@ -34,102 +28,6 @@ type PacketMetadata struct { Forward *ForwardMetadata `json:"forward"` } -func (s *IntegrationTestSuite) runIBCRelayer() { - s.T().Log("starting Hermes relayer container...") - - 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[relayerAccountIndex] - gaiaBRly := s.chainB.genesisAccounts[relayerAccountIndex] - - hermesCfgPath := path.Join(tmpDir, "hermes") - - s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755)) - _, err = copyFile( - filepath.Join("./scripts/", "hermes_bootstrap.sh"), - filepath.Join(hermesCfgPath, "hermes_bootstrap.sh"), - ) - s.Require().NoError(err) - - s.hermesResource, err = s.dkrPool.RunWithOptions( - &dockertest.RunOptions{ - 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, - Mounts: []string{ - fmt.Sprintf("%s/:/root/hermes", hermesCfgPath), - }, - PortBindings: map[docker.Port][]docker.PortBinding{ - "3031/tcp": {{HostIP: "", HostPort: "3031"}}, - }, - 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:]), - }, - Entrypoint: []string{ - "sh", - "-c", - "chmod +x /root/hermes/hermes_bootstrap.sh && /root/hermes/hermes_bootstrap.sh", - }, - }, - noRestart, - ) - s.Require().NoError(err) - - endpoint := fmt.Sprintf("http://%s/state", s.hermesResource.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 container: %s", s.hermesResource.Container.ID) - - // XXX: Give time to both networks to start, otherwise we might see gRPC - // transport errors. - time.Sleep(10 * time.Second) - - // create the client, connection and channel between the two Gaia chains - s.createConnection() - time.Sleep(10 * time.Second) - s.createChannel() -} - func (s *IntegrationTestSuite) sendIBC(c *chain, valIdx int, sender, recipient, token, fees, note string) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -158,6 +56,99 @@ func (s *IntegrationTestSuite) sendIBC(c *chain, valIdx int, sender, recipient, s.T().Log("successfully sent IBC tokens") } +func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID, srcChannelID, denom string, sendAmt, timeOutOffset, numMsg int) bool { + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + hermesCmd := []string{ + hermesBinary, + fmt.Sprintf("--config=%s", configPath), + "tx", + "ft-transfer", + fmt.Sprintf("--dst-chain=%s", dstChainID), + fmt.Sprintf("--src-chain=%s", srcChainID), + fmt.Sprintf("--src-channel=%s", srcChannelID), + fmt.Sprintf("--src-port=%s", "transfer"), + fmt.Sprintf("--amount=%v", sendAmt), + fmt.Sprintf("--denom=%s", denom), + fmt.Sprintf("--timeout-height-offset=%v", timeOutOffset), + fmt.Sprintf("--number-msgs=%v", numMsg), + } + + stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) + if strings.Contains(stdout, "ERROR") || strings.Contains(stderr, "ERROR") { + return false + } + + return true +} + +func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + hermesCmd := []string{ + hermesBinary, + fmt.Sprintf("--config=%s", configPath), + "clear", + "packets", + fmt.Sprintf("--chain=%s", chainID), + fmt.Sprintf("--channel=%s", channelID), + fmt.Sprintf("--port=%s", "transfer"), + } + + stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) + if strings.Contains(stdout, "ERROR") || strings.Contains(stderr, "ERROR") { + return false + } + + return true +} + +func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) bool { + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + hermesCmd := []string{ + hermesBinary, + fmt.Sprintf("--config=%s", configPath), + "query", + "packet", + "pending", + fmt.Sprintf("--chain=%s", chainID), + fmt.Sprintf("--channel=%s", channelID), + fmt.Sprintf("--port=%s", "transfer"), + } + + stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) + fmt.Println("stdout pending packets:", stdout) + fmt.Println("stderr pending packets:", stderr) + + // "start: Sequence" is the pending packets sequence + if strings.Contains(stdout, "Sequence") { + return true + } + + return false +} + +func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + scrRelayerBalance, err := getSpecificBalance( + chainAAPIEndpoint, + s.chainA.genesisAccounts[relayerAccountIndexHermes1].keyInfo.GetAddress().String(), + uatomDenom) + s.Require().NoError(err) + + chainBAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainB.id][0].GetHostPort("1317/tcp")) + dstRelayerBalance, err := getSpecificBalance( + chainBAPIEndpoint, + s.chainB.genesisAccounts[relayerAccountIndexHermes1].keyInfo.GetAddress().String(), + uatomDenom) + s.Require().NoError(err) + + return scrRelayerBalance, dstRelayerBalance +} + func (s *IntegrationTestSuite) createConnection() { s.T().Logf("connecting %s and %s chains via IBC", s.chainA.id, s.chainB.id) @@ -168,7 +159,7 @@ func (s *IntegrationTestSuite) createConnection() { Context: ctx, AttachStdout: true, AttachStderr: true, - Container: s.hermesResource.Container.ID, + Container: s.hermesResource0.Container.ID, User: "root", Cmd: []string{ "hermes", @@ -211,7 +202,7 @@ func (s *IntegrationTestSuite) createChannel() { Context: ctx, AttachStdout: true, AttachStderr: true, - Container: s.hermesResource.Container.ID, + Container: s.hermesResource0.Container.ID, User: "root", Cmd: []string{ "hermes", @@ -249,7 +240,7 @@ func (s *IntegrationTestSuite) createChannel() { } func (s *IntegrationTestSuite) testIBCTokenTransfer() { - time.Sleep(30 * time.Second) + // time.Sleep(30 * time.Second) s.Run("send_uatom_to_chainB", func() { // require the recipient account receives the IBC tokens (IBC packets ACKd) var ( From a88ba48cbb46bfe28779cf9077b6fcda189a03ad Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 25 May 2023 13:13:20 +0200 Subject: [PATCH 04/22] test: add ibc-bypass-msg test --- tests/e2e/e2e_test.go | 106 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 13 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 58cba8a906d..70f37388f17 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -2,21 +2,25 @@ package e2e import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" + "time" ) var ( - runBankTest = true - runBypassMinFeeTest = true - runEncodeTest = true - runEvidenceTest = true - runFeeGrantTest = true - runGlobalFeesTest = true - runGovTest = true + runBankTest = false + runBypassMinFeeTest = false + runEncodeTest = false + runEvidenceTest = false + runFeeGrantTest = false + runGlobalFeesTest = false + runGovTest = false runIBCTest = true - runSlashingTest = true - runStakingAndDistributionTest = true - runVestingTest = true - runRestInterfacesTest = true + runSlashingTest = false + runStakingAndDistributionTest = false + runVestingTest = false + runRestInterfacesTest = false ) func (s *IntegrationTestSuite) TestRestInterfaces() { @@ -86,8 +90,84 @@ func (s *IntegrationTestSuite) TestIBC() { s.T().Skip() } s.testIBCTokenTransfer() - s.testMultihopIBCTokenTransfer() - s.testFailedMultihopIBCTokenTransfer() + //s.testMultihopIBCTokenTransfer() + //s.testFailedMultihopIBCTokenTransfer() + + // stop hermes0 to prevent hermes0 relaying transactions + s.Require().NoError(s.dkrPool.Purge(s.hermesResource0)) + + s.testIBCBypassMsg() +} + +func (s *IntegrationTestSuite) testIBCBypassMsg() { + + // submit gov proposal to change bypass-msg param to + // ["/ibc.core.channel.v1.MsgRecvPacket", + // "/ibc.core.channel.v1.MsgAcknowledgement", + // "/ibc.core.client.v1.MsgUpdateClient"] + submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() + submitter := submitterAddr.String() + proposalCounter++ + s.govProposeNewBypassMsgs([]string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + 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.T().Logf("testing transaction contains only ibc bypass messages") + ok := s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) + s.Require().True(ok) + + scrRelayerBalanceBefore, dstRelayerBalanceBefore := s.queryRelayerWalletsBalances() + + pass := s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + pendingPacketsExist := s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().False(pendingPacketsExist) + + // confirm relayer wallets do not pay fees + scrRelayerBalanceAfter, dstRelayerBalanceAfter := s.queryRelayerWalletsBalances() + s.Require().Equal(scrRelayerBalanceBefore.String(), scrRelayerBalanceAfter.String()) + s.Require().Equal(dstRelayerBalanceBefore.String(), dstRelayerBalanceAfter.String()) + + // test 2: test transactions contains both bypass and non-bypass msgs (ibc msg mix with time out msg) + s.T().Logf("testing transaction contains both bypass and non-bypass messages") + ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) + s.Require().True(ok) + // make sure that the transaction is timeout + time.Sleep(3) + pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().True(pendingPacketsExist) + + pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().False(pass) + // clear packets with paying fee, to not influence the next transaction + pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + + // test 3: test transactions contains both bypass and non-bypass msgs (ibc msg mix with time out msg) + s.T().Logf("testing bypass messages exceed MaxBypassGasUsage") + ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) + s.Require().True(ok) + pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().False(pass) + + pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().True(pendingPacketsExist) + + pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + + // set the default bypass-msg back + //proposalCounter++ + //s.govProposeNewBypassMsgs([]string{ + // sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + // sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + // sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + // sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + // sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{})}, proposalCounter, submitter, standardFees.String()) } func (s *IntegrationTestSuite) TestSlashing() { From e6dbb96ccf17be30552e3151fb1b7d35cad9afbc Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 25 May 2023 13:13:40 +0200 Subject: [PATCH 05/22] test: add hermes config --- tests/e2e/scripts/hermes1_bootstrap.sh | 152 +++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100755 tests/e2e/scripts/hermes1_bootstrap.sh diff --git a/tests/e2e/scripts/hermes1_bootstrap.sh b/tests/e2e/scripts/hermes1_bootstrap.sh new file mode 100755 index 00000000000..990dab38c41 --- /dev/null +++ b/tests/e2e/scripts/hermes1_bootstrap.sh @@ -0,0 +1,152 @@ +#!/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 < Date: Thu, 25 May 2023 13:26:20 +0200 Subject: [PATCH 06/22] test: enable all e2e test --- tests/e2e/e2e_ibc_test.go | 5 +---- tests/e2e/e2e_test.go | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 4e629d370ef..b799a59cbf5 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -119,10 +119,7 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel fmt.Sprintf("--port=%s", "transfer"), } - stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) - fmt.Println("stdout pending packets:", stdout) - fmt.Println("stderr pending packets:", stderr) - + stdout, _ := s.executeHermesCommand(ctx, hermesCmd) // "start: Sequence" is the pending packets sequence if strings.Contains(stdout, "Sequence") { return true diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 70f37388f17..b25b4e8e51e 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -9,18 +9,18 @@ import ( ) var ( - runBankTest = false - runBypassMinFeeTest = false - runEncodeTest = false - runEvidenceTest = false - runFeeGrantTest = false - runGlobalFeesTest = false - runGovTest = false + runBankTest = true + runBypassMinFeeTest = true + runEncodeTest = true + runEvidenceTest = true + runFeeGrantTest = true + runGlobalFeesTest = true + runGovTest = true runIBCTest = true - runSlashingTest = false - runStakingAndDistributionTest = false - runVestingTest = false - runRestInterfacesTest = false + runSlashingTest = true + runStakingAndDistributionTest = true + runVestingTest = true + runRestInterfacesTest = true ) func (s *IntegrationTestSuite) TestRestInterfaces() { From e0216d409c82eb7352db0497025e1c7bee87b15c Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 25 May 2023 14:29:57 +0200 Subject: [PATCH 07/22] fix: tearDownSuite in e2e test --- tests/e2e/e2e_setup_test.go | 26 +++++++++++++++----------- tests/e2e/e2e_test.go | 6 +++--- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index bcdbc1be86a..cca37088ee9 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -80,14 +80,15 @@ 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() - proposalCounter = 0 + 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() + proposalCounter = 0 + HermesResource0Purged = false ) type IntegrationTestSuite struct { @@ -176,9 +177,12 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.T().Log("tearing down e2e integration test suite...") - if runIBCTest { - // s.hermesResource0 already purged in TestIBC() - s.Require().NoError(s.dkrPool.Purge(s.hermesResource1)) + 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)) } for _, vr := range s.valResources { diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index b25b4e8e51e..30fa78ddb9a 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -90,12 +90,12 @@ func (s *IntegrationTestSuite) TestIBC() { s.T().Skip() } s.testIBCTokenTransfer() - //s.testMultihopIBCTokenTransfer() - //s.testFailedMultihopIBCTokenTransfer() + s.testMultihopIBCTokenTransfer() + s.testFailedMultihopIBCTokenTransfer() // stop hermes0 to prevent hermes0 relaying transactions s.Require().NoError(s.dkrPool.Purge(s.hermesResource0)) - + HermesResource0Purged = true s.testIBCBypassMsg() } From 727bcd06c3609b6ec845e1b291362c2b426038a8 Mon Sep 17 00:00:00 2001 From: yaruwangway <69694322+yaruwangway@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:23:25 +0200 Subject: [PATCH 08/22] Apply suggestions from code review Co-authored-by: Simon Noetzlin --- tests/e2e/scripts/hermes1_bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/scripts/hermes1_bootstrap.sh b/tests/e2e/scripts/hermes1_bootstrap.sh index 990dab38c41..049c61b8ad4 100755 --- a/tests/e2e/scripts/hermes1_bootstrap.sh +++ b/tests/e2e/scripts/hermes1_bootstrap.sh @@ -122,7 +122,7 @@ store_prefix = 'ibc' max_gas = 6000000 gas_price = { price = 0, denom = 'uatom' } gas_multiplier = 1.2 -clock_drift = '1m' # to accomdate docker containers +clock_drift = '1m' # to accommodate docker containers trusting_period = '14days' trust_threshold = { numerator = '1', denominator = '3' } @@ -138,7 +138,7 @@ store_prefix = 'ibc' max_gas = 6000000 gas_price = { price = 0, denom = 'uatom' } gas_multiplier = 1.2 -clock_drift = '1m' # to accomdate docker containers +clock_drift = '1m' # to accommodate docker containers trusting_period = '14days' trust_threshold = { numerator = '1', denominator = '3' } EOF From 521a51ff03538578ed597ac16522061a4b062c69 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 1 Jun 2023 15:59:35 +0200 Subject: [PATCH 09/22] update according to comments --- tests/e2e/e2e_bypassminfee_test.go | 75 ++++++++++++++++++++++++++++++ tests/e2e/e2e_ibc_test.go | 3 +- tests/e2e/e2e_test.go | 75 ------------------------------ 3 files changed, 76 insertions(+), 77 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 61be12f0b6a..7b7a0c0736b 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -4,6 +4,9 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" + "time" ) func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward(endpoint string) { @@ -95,3 +98,75 @@ func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward(endpoint string) { } } } + +func (s *IntegrationTestSuite) testIBCBypassMsg() { + + // submit gov proposal to change bypass-msg param to + // ["/ibc.core.channel.v1.MsgRecvPacket", + // "/ibc.core.channel.v1.MsgAcknowledgement", + // "/ibc.core.client.v1.MsgUpdateClient"] + submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() + submitter := submitterAddr.String() + proposalCounter++ + s.govProposeNewBypassMsgs([]string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + 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.T().Logf("testing transaction contains only ibc bypass messages") + ok := s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) + s.Require().True(ok) + + scrRelayerBalanceBefore, dstRelayerBalanceBefore := s.queryRelayerWalletsBalances() + + pass := s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + pendingPacketsExist := s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().False(pendingPacketsExist) + + // confirm relayer wallets do not pay fees + scrRelayerBalanceAfter, dstRelayerBalanceAfter := s.queryRelayerWalletsBalances() + s.Require().Equal(scrRelayerBalanceBefore.String(), scrRelayerBalanceAfter.String()) + s.Require().Equal(dstRelayerBalanceBefore.String(), dstRelayerBalanceAfter.String()) + + // test 2: test transactions contains both bypass and non-bypass msgs (sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}) + s.T().Logf("testing transaction contains both bypass and non-bypass messages") + // hermesTransfer wtih --timeout-height-offset=1 + ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) + s.Require().True(ok) + // make sure that the transaction is timeout + time.Sleep(3) + pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().True(pendingPacketsExist) + + pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().False(pass) + // clear packets with paying fee, to not influence the next transaction + pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + + // test 3: test bypass-msgs exceed the MaxBypassGasUsage + s.T().Logf("testing bypass messages exceed MaxBypassGasUsage") + ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) + s.Require().True(ok) + pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().False(pass) + + pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + s.Require().True(pendingPacketsExist) + + pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) + s.Require().True(pass) + + // set the default bypass-msg back + proposalCounter++ + s.govProposeNewBypassMsgs([]string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{})}, proposalCounter, submitter, standardFees.String()) +} diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index b799a59cbf5..872ff99e7e9 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -56,7 +56,7 @@ func (s *IntegrationTestSuite) sendIBC(c *chain, valIdx int, sender, recipient, s.T().Log("successfully sent IBC tokens") } -func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID, srcChannelID, denom string, sendAmt, timeOutOffset, numMsg int) bool { +func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID, srcChannelID, denom string, sendAmt, timeOutOffset, numMsg int) (success bool) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -237,7 +237,6 @@ func (s *IntegrationTestSuite) createChannel() { } func (s *IntegrationTestSuite) testIBCTokenTransfer() { - // time.Sleep(30 * time.Second) s.Run("send_uatom_to_chainB", func() { // require the recipient account receives the IBC tokens (IBC packets ACKd) var ( diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 30fa78ddb9a..c2edd641fc5 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -2,10 +2,6 @@ package e2e import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" - ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" - "time" ) var ( @@ -99,77 +95,6 @@ func (s *IntegrationTestSuite) TestIBC() { s.testIBCBypassMsg() } -func (s *IntegrationTestSuite) testIBCBypassMsg() { - - // submit gov proposal to change bypass-msg param to - // ["/ibc.core.channel.v1.MsgRecvPacket", - // "/ibc.core.channel.v1.MsgAcknowledgement", - // "/ibc.core.client.v1.MsgUpdateClient"] - submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() - submitter := submitterAddr.String() - proposalCounter++ - s.govProposeNewBypassMsgs([]string{ - sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - 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.T().Logf("testing transaction contains only ibc bypass messages") - ok := s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) - s.Require().True(ok) - - scrRelayerBalanceBefore, dstRelayerBalanceBefore := s.queryRelayerWalletsBalances() - - pass := s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) - s.Require().True(pass) - pendingPacketsExist := s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) - s.Require().False(pendingPacketsExist) - - // confirm relayer wallets do not pay fees - scrRelayerBalanceAfter, dstRelayerBalanceAfter := s.queryRelayerWalletsBalances() - s.Require().Equal(scrRelayerBalanceBefore.String(), scrRelayerBalanceAfter.String()) - s.Require().Equal(dstRelayerBalanceBefore.String(), dstRelayerBalanceAfter.String()) - - // test 2: test transactions contains both bypass and non-bypass msgs (ibc msg mix with time out msg) - s.T().Logf("testing transaction contains both bypass and non-bypass messages") - ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) - s.Require().True(ok) - // make sure that the transaction is timeout - time.Sleep(3) - pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) - s.Require().True(pendingPacketsExist) - - pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) - s.Require().False(pass) - // clear packets with paying fee, to not influence the next transaction - pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) - s.Require().True(pass) - - // test 3: test transactions contains both bypass and non-bypass msgs (ibc msg mix with time out msg) - s.T().Logf("testing bypass messages exceed MaxBypassGasUsage") - ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) - s.Require().True(ok) - pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) - s.Require().False(pass) - - pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) - s.Require().True(pendingPacketsExist) - - pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) - s.Require().True(pass) - - // set the default bypass-msg back - //proposalCounter++ - //s.govProposeNewBypassMsgs([]string{ - // sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), - // sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - // sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), - // sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), - // sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{})}, proposalCounter, submitter, standardFees.String()) -} - func (s *IntegrationTestSuite) TestSlashing() { if !runSlashingTest { s.T().Skip() From 907add4bcfdbff736ea9738efe7e0db73e25c4c3 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 1 Jun 2023 16:47:22 +0200 Subject: [PATCH 10/22] chore: add comments to code --- tests/e2e/e2e_setup_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index cca37088ee9..3b398f2bd49 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -602,7 +602,7 @@ func noRestart(config *docker.HostConfig) { } } -// hermes0 is for ibc and packet-forward-middleware test +// 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...") @@ -699,7 +699,9 @@ func (s *IntegrationTestSuite) runIBCRelayer0() { s.createChannel() } -// hermes1 is for bypass-msg test +// 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...") From 808d292708e348c26f859aa6d14291de0afcaec9 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 1 Jun 2023 16:49:49 +0200 Subject: [PATCH 11/22] chore: correct typo --- tests/e2e/e2e_bypassminfee_test.go | 22 +++++++++++----------- tests/e2e/e2e_setup_test.go | 8 ++++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 7b7a0c0736b..821fca37390 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -117,14 +117,14 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { // // test 1: transaction only contains bypass-msgs, pass s.T().Logf("testing transaction contains only ibc bypass messages") - ok := s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) + ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) s.Require().True(ok) scrRelayerBalanceBefore, dstRelayerBalanceBefore := s.queryRelayerWalletsBalances() - pass := s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) - pendingPacketsExist := s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pendingPacketsExist) // confirm relayer wallets do not pay fees @@ -135,30 +135,30 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { // test 2: test transactions contains both bypass and non-bypass msgs (sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}) s.T().Logf("testing transaction contains both bypass and non-bypass messages") // hermesTransfer wtih --timeout-height-offset=1 - ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) + ok = s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) s.Require().True(ok) // make sure that the transaction is timeout time.Sleep(3) - pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist = s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) - pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + pass = s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pass) // clear packets with paying fee, to not influence the next transaction - pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) + pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) // test 3: test bypass-msgs exceed the MaxBypassGasUsage s.T().Logf("testing bypass messages exceed MaxBypassGasUsage") - ok = s.hermesTransfer(hermesCofigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) + ok = s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) s.Require().True(ok) - pass = s.hermesClearPacket(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + pass = s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pass) - pendingPacketsExist = s.hermesPendingPackets(hermesCofigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist = s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) - pass = s.hermesClearPacket(hermesCofigWithGasPrices, s.chainA.id, transferChannel) + pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) // set the default bypass-msg back diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 3b398f2bd49..3f643f63710 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -73,10 +73,10 @@ const ( proposalAddConsumerChainFilename = "proposal_add_consumer.json" proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" - hermesBinary = "hermes" - hermesCofigWithGasPrices = "/root/.hermes/config.toml" - hermesCofigNoGasPrices = "/root/.hermes/config-zero.toml" - transferChannel = "channel-0" + hermesBinary = "hermes" + hermesConfigWithGasPrices = "/root/.hermes/config.toml" + hermesConfigNoGasPrices = "/root/.hermes/config-zero.toml" + transferChannel = "channel-0" ) var ( From 236c3f2fbe53fa7e249ea7465dd4e12ddd044c1a Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 1 Jun 2023 17:05:21 +0200 Subject: [PATCH 12/22] refactor bypass msg test --- tests/e2e/e2e_bypassminfee_test.go | 44 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 821fca37390..9010238f7d7 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -116,6 +116,23 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { // 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{}) + s.testTxContainsMixBypassNonBypassMsg() + // test 3: test bypass-msgs exceed the MaxBypassGasUsage + s.testBypassMsgsExceedMaxBypassGasLimit() + + // set the default bypass-msg back + proposalCounter++ + s.govProposeNewBypassMsgs([]string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{})}, proposalCounter, submitter, standardFees.String()) +} + +func (s *IntegrationTestSuite) testTxContainsOnlyIBCBypassMsg() { s.T().Logf("testing transaction contains only ibc bypass messages") ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 1) s.Require().True(ok) @@ -131,42 +148,35 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { scrRelayerBalanceAfter, dstRelayerBalanceAfter := s.queryRelayerWalletsBalances() s.Require().Equal(scrRelayerBalanceBefore.String(), scrRelayerBalanceAfter.String()) s.Require().Equal(dstRelayerBalanceBefore.String(), dstRelayerBalanceAfter.String()) +} - // test 2: test transactions contains both bypass and non-bypass msgs (sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}) +func (s *IntegrationTestSuite) testTxContainsMixBypassNonBypassMsg() { s.T().Logf("testing transaction contains both bypass and non-bypass messages") // hermesTransfer wtih --timeout-height-offset=1 - ok = s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) + ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) s.Require().True(ok) // make sure that the transaction is timeout time.Sleep(3) - pendingPacketsExist = s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) - pass = s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pass) // clear packets with paying fee, to not influence the next transaction pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) +} - // test 3: test bypass-msgs exceed the MaxBypassGasUsage +func (s *IntegrationTestSuite) testBypassMsgsExceedMaxBypassGasLimit() { s.T().Logf("testing bypass messages exceed MaxBypassGasUsage") - ok = s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) + ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1000, 12) s.Require().True(ok) - pass = s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pass := s.hermesClearPacket(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().False(pass) - pendingPacketsExist = s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) + pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) pass = s.hermesClearPacket(hermesConfigWithGasPrices, s.chainA.id, transferChannel) s.Require().True(pass) - - // set the default bypass-msg back - proposalCounter++ - s.govProposeNewBypassMsgs([]string{ - sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{})}, proposalCounter, submitter, standardFees.String()) } From fb8a895a86ac19b6ca732f8f20815f9ee444abba Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 1 Jun 2023 17:38:34 +0200 Subject: [PATCH 13/22] fix: parse query pending packet result --- tests/e2e/e2e_ibc_test.go | 12 ++++++++---- tests/e2e/util.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 872ff99e7e9..fc68ada6a2b 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -105,7 +105,7 @@ func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID return true } -func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) bool { +func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) (PendingPackets bool) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() hermesCmd := []string{ @@ -121,11 +121,15 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel stdout, _ := s.executeHermesCommand(ctx, hermesCmd) // "start: Sequence" is the pending packets sequence - if strings.Contains(stdout, "Sequence") { - return true + + unreceivedPackets, err := parsePendingPacketResult(stdout) + s.Require().NoError(err) + + if len(unreceivedPackets) == 0 { + return false } - return false + return true } func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { diff --git a/tests/e2e/util.go b/tests/e2e/util.go index ae136313e3c..8834cc1afe0 100644 --- a/tests/e2e/util.go +++ b/tests/e2e/util.go @@ -1,7 +1,9 @@ package e2e import ( + "encoding/json" "fmt" + "strings" "github.com/cosmos/cosmos-sdk/codec/unknownproto" sdktx "github.com/cosmos/cosmos-sdk/types/tx" @@ -50,3 +52,40 @@ func concatFlags(originalCollection []string, commandFlags []string, generalFlag return originalCollection } + +type Summary struct { + Src PendingPackets `json:"src"` + Dst PendingPackets `json:"dst"` +} + +type PendingPackets struct { + UnreceivedPackets []Collated `json:"unreceived_packets"` + UnreceivedAcks []Collated `json:"unreceived_acks"` +} + +type Collated struct { + Start Sequence `json:"start"` + End Sequence `json:"end"` +} + +type Sequence struct { + Value int `json:"value"` +} + +func parsePendingPacketResult(output string) ([]Collated, error) { + var summary Summary + var res string + index := strings.Index(output, "SUCCESS") + if index != -1 { + res = output[index:] + } else { + return []Collated{}, fmt.Errorf("unexpected query pending packet result") + } + + err := json.Unmarshal([]byte(res), &summary) + if err != nil { + return []Collated{}, fmt.Errorf("Error parsing query pending packet result:", err) + } + + return summary.Src.UnreceivedPackets, nil +} From 65c6e8acd3bf697ae722d6539c3d0dcf86a1eab5 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 2 Jun 2023 13:05:20 +0200 Subject: [PATCH 14/22] fix: format print error --- tests/e2e/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/util.go b/tests/e2e/util.go index 8834cc1afe0..7f41dd60c9e 100644 --- a/tests/e2e/util.go +++ b/tests/e2e/util.go @@ -84,7 +84,7 @@ func parsePendingPacketResult(output string) ([]Collated, error) { err := json.Unmarshal([]byte(res), &summary) if err != nil { - return []Collated{}, fmt.Errorf("Error parsing query pending packet result:", err) + return []Collated{}, fmt.Errorf("Error parsing query pending packet result %v\n:", err) } return summary.Src.UnreceivedPackets, nil From 173dc29cfd7ba0ddc7cef4d9ef5029f8123fd03b Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 2 Jun 2023 18:34:08 +0200 Subject: [PATCH 15/22] fix: pending packets parsing --- tests/e2e/e2e_ibc_test.go | 13 ++++--------- tests/e2e/util.go | 40 --------------------------------------- 2 files changed, 4 insertions(+), 49 deletions(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index fc68ada6a2b..c19fce2ffe5 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -120,16 +120,11 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel } stdout, _ := s.executeHermesCommand(ctx, hermesCmd) - // "start: Sequence" is the pending packets sequence + stdout = strings.ReplaceAll(stdout, " ", "") + stdout = strings.ReplaceAll(stdout, "\n", "") - unreceivedPackets, err := parsePendingPacketResult(stdout) - s.Require().NoError(err) - - if len(unreceivedPackets) == 0 { - return false - } - - return true + // Check if "unreceived_packets" exists in "src" + return !strings.Contains(stdout, "src:PendingPackets{unreceived_packets:[]") } func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { diff --git a/tests/e2e/util.go b/tests/e2e/util.go index 7f41dd60c9e..40a805bbfa3 100644 --- a/tests/e2e/util.go +++ b/tests/e2e/util.go @@ -1,10 +1,7 @@ package e2e import ( - "encoding/json" "fmt" - "strings" - "github.com/cosmos/cosmos-sdk/codec/unknownproto" sdktx "github.com/cosmos/cosmos-sdk/types/tx" ) @@ -52,40 +49,3 @@ func concatFlags(originalCollection []string, commandFlags []string, generalFlag return originalCollection } - -type Summary struct { - Src PendingPackets `json:"src"` - Dst PendingPackets `json:"dst"` -} - -type PendingPackets struct { - UnreceivedPackets []Collated `json:"unreceived_packets"` - UnreceivedAcks []Collated `json:"unreceived_acks"` -} - -type Collated struct { - Start Sequence `json:"start"` - End Sequence `json:"end"` -} - -type Sequence struct { - Value int `json:"value"` -} - -func parsePendingPacketResult(output string) ([]Collated, error) { - var summary Summary - var res string - index := strings.Index(output, "SUCCESS") - if index != -1 { - res = output[index:] - } else { - return []Collated{}, fmt.Errorf("unexpected query pending packet result") - } - - err := json.Unmarshal([]byte(res), &summary) - if err != nil { - return []Collated{}, fmt.Errorf("Error parsing query pending packet result %v\n:", err) - } - - return summary.Src.UnreceivedPackets, nil -} From 10d1d73f1615dc2e3e1acc4c90155bd162cb051e Mon Sep 17 00:00:00 2001 From: yaruwangway <69694322+yaruwangway@users.noreply.github.com> Date: Mon, 5 Jun 2023 17:07:35 +0200 Subject: [PATCH 16/22] Apply suggestions from code review Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --- tests/e2e/e2e_bypassminfee_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index 9010238f7d7..fb2cff88ecb 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -152,11 +152,11 @@ func (s *IntegrationTestSuite) testTxContainsOnlyIBCBypassMsg() { func (s *IntegrationTestSuite) testTxContainsMixBypassNonBypassMsg() { s.T().Logf("testing transaction contains both bypass and non-bypass messages") - // hermesTransfer wtih --timeout-height-offset=1 + // hermesTransfer with --timeout-height-offset=1 ok := s.hermesTransfer(hermesConfigWithGasPrices, s.chainA.id, s.chainB.id, transferChannel, uatomDenom, 100, 1, 1) s.Require().True(ok) // make sure that the transaction is timeout - time.Sleep(3) + time.Sleep(3 * time.Second) pendingPacketsExist := s.hermesPendingPackets(hermesConfigNoGasPrices, s.chainA.id, transferChannel) s.Require().True(pendingPacketsExist) From 31512ce1bc12f4640c50b85828cdc96ed508f55b Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 6 Jun 2023 11:18:16 +0200 Subject: [PATCH 17/22] docs: fix dead link --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 19d503ab37f..420d6daaa1e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -25,7 +25,7 @@ Welcome to the documentation of the **Cosmos Hub application: `gaia`**. ## Setup Your Own `gaia` Testnet -- [Setup your own `gaia` testnet](https://github.com/cosmos/testnets/tree/master/local/previous-local-testnets/theta) +- [Setup your own `gaia` testnet](https://github.com/cosmos/testnets/tree/master/local/previous-local-testnets/v7-theta) ## Additional Resources From 02cf08cd60fd45ed2d5669f8626f8caa467ed208 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 6 Jun 2023 11:51:15 +0200 Subject: [PATCH 18/22] chore: fix lint --- tests/e2e/e2e_bypassminfee_test.go | 10 ++++++---- tests/e2e/e2e_setup_test.go | 1 - tests/e2e/util.go | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index fb2cff88ecb..2901c557fef 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -1,12 +1,13 @@ package e2e import ( + "time" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" - "time" ) func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward(endpoint string) { @@ -100,7 +101,6 @@ func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward(endpoint string) { } func (s *IntegrationTestSuite) testIBCBypassMsg() { - // submit gov proposal to change bypass-msg param to // ["/ibc.core.channel.v1.MsgRecvPacket", // "/ibc.core.channel.v1.MsgAcknowledgement", @@ -111,7 +111,8 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { s.govProposeNewBypassMsgs([]string{ sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), - sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{})}, proposalCounter, submitter, standardFees.String()) + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + }, proposalCounter, submitter, standardFees.String()) // use hermes1 to test default ibc bypass-msg // @@ -129,7 +130,8 @@ func (s *IntegrationTestSuite) testIBCBypassMsg() { sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), - sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{})}, proposalCounter, submitter, standardFees.String()) + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), + }, proposalCounter, submitter, standardFees.String()) } func (s *IntegrationTestSuite) testTxContainsOnlyIBCBypassMsg() { diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 3f643f63710..bc3d54b68e5 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -162,7 +162,6 @@ func (s *IntegrationTestSuite) SetupSuite() { time.Sleep(10 * time.Second) s.runIBCRelayer0() s.runIBCRelayer1() - } func (s *IntegrationTestSuite) TearDownSuite() { diff --git a/tests/e2e/util.go b/tests/e2e/util.go index 40a805bbfa3..ae136313e3c 100644 --- a/tests/e2e/util.go +++ b/tests/e2e/util.go @@ -2,6 +2,7 @@ package e2e import ( "fmt" + "github.com/cosmos/cosmos-sdk/codec/unknownproto" sdktx "github.com/cosmos/cosmos-sdk/types/tx" ) From 8afd21a75848e37c0ce3ab5043ca4fbe284091ba Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 6 Jun 2023 13:26:51 +0200 Subject: [PATCH 19/22] chore: lint fix --- tests/e2e/e2e_ibc_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index c19fce2ffe5..fe5ac08af27 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -83,6 +83,7 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID return true } +// nolint: unparam func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -105,7 +106,7 @@ func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID return true } -func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) (PendingPackets bool) { +func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) (pendingPackets bool) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() hermesCmd := []string{ @@ -124,7 +125,7 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel stdout = strings.ReplaceAll(stdout, "\n", "") // Check if "unreceived_packets" exists in "src" - return !strings.Contains(stdout, "src:PendingPackets{unreceived_packets:[]") + return !strings.Contains(stdout, "src:pendingPackets{unreceived_packets:[]") } func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { From 768a907502db5970b79d76430345f4f9108a25b8 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 6 Jun 2023 13:43:08 +0200 Subject: [PATCH 20/22] chore: lint fix1 --- tests/e2e/e2e_ibc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index fe5ac08af27..d4bcf65e2ec 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -83,7 +83,7 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID return true } -// nolint: unparam +//nolint: unparam func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() From 4a131674d1339dde71569f36f436cc68cc8e4bf5 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Tue, 6 Jun 2023 17:26:07 +0200 Subject: [PATCH 21/22] chore: remove nolint --- tests/e2e/e2e_ibc_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index d4bcf65e2ec..cc674e7f968 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -83,7 +83,6 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID return true } -//nolint: unparam func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() From 1ee2798bf09a2403cc15ad613af396cfb35d15a4 Mon Sep 17 00:00:00 2001 From: yaruwangway <69694322+yaruwangway@users.noreply.github.com> Date: Tue, 6 Jun 2023 18:08:38 +0200 Subject: [PATCH 22/22] Update tests/e2e/e2e_ibc_test.go --- tests/e2e/e2e_ibc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index cc674e7f968..76a5bd7d406 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -83,7 +83,7 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID return true } -func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { +func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { //nolint:unparam ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel()