From 669d20623a60b85ba2291739a800afb9244e71ae Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 8 Jun 2023 10:20:44 +0200 Subject: [PATCH 1/3] fix: e2e test --- tests/e2e/e2e_ibc_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 76a5bd7d406..f5936b5eb5e 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -122,9 +122,10 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel stdout, _ := s.executeHermesCommand(ctx, hermesCmd) stdout = strings.ReplaceAll(stdout, " ", "") stdout = strings.ReplaceAll(stdout, "\n", "") + stdout = strings.ToLower(stdout) // 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 e46b403aa98a21267d1dd2dc72841a10f659466c Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Thu, 8 Jun 2023 17:18:55 +0200 Subject: [PATCH 2/3] fix: parsing hermes pending packet query result --- tests/e2e/e2e_exec_test.go | 4 ++-- tests/e2e/e2e_ibc_test.go | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 4f16db42d88..c85c11d42e4 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -617,7 +617,7 @@ func (s *IntegrationTestSuite) executeGaiaTxCommand(ctx context.Context, c *chai } } -func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesCmd []string) (string, string) { +func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesCmd []string) ([]byte, []byte) { var ( outBuf bytes.Buffer errBuf bytes.Buffer @@ -643,7 +643,7 @@ func (s *IntegrationTestSuite) executeHermesCommand(ctx context.Context, hermesC stdOut := outBuf.Bytes() stdErr := errBuf.Bytes() - return string(stdOut), string(stdErr) + return stdOut, stdErr } 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 f5936b5eb5e..5ecca234e0f 100644 --- a/tests/e2e/e2e_ibc_test.go +++ b/tests/e2e/e2e_ibc_test.go @@ -76,14 +76,14 @@ func (s *IntegrationTestSuite) hermesTransfer(configPath, srcChainID, dstChainID } stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) - if strings.Contains(stdout, "ERROR") || strings.Contains(stderr, "ERROR") { + if strings.Contains(string(stdout), "ERROR") || strings.Contains(string(stderr), "ERROR") { return false } return true } -func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) bool { //nolint:unparam +func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID string) (success bool) { //nolint:unparam ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -98,18 +98,31 @@ func (s *IntegrationTestSuite) hermesClearPacket(configPath, chainID, channelID } stdout, stderr := s.executeHermesCommand(ctx, hermesCmd) - if strings.Contains(stdout, "ERROR") || strings.Contains(stderr, "ERROR") { + if strings.Contains(string(stdout), "ERROR") || strings.Contains(string(stderr), "ERROR") { return false } return true } +type Response struct { + Result struct { + Dst struct { + UnreceivedPackets []interface{} `json:"unreceived_packets"` + } `json:"dst"` + Src struct { + UnreceivedPackets []interface{} `json:"unreceived_packets"` + } `json:"src"` + } `json:"result"` + Status string `json:"status"` +} + func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channelID string) (pendingPackets bool) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() hermesCmd := []string{ hermesBinary, + "--json", fmt.Sprintf("--config=%s", configPath), "query", "packet", @@ -120,12 +133,13 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel } stdout, _ := s.executeHermesCommand(ctx, hermesCmd) - stdout = strings.ReplaceAll(stdout, " ", "") - stdout = strings.ReplaceAll(stdout, "\n", "") - stdout = strings.ToLower(stdout) + + var response Response + err := json.Unmarshal(stdout, &response) + s.Require().NoError(err) // Check if "unreceived_packets" exists in "src" - return !strings.Contains(stdout, "src:pendingpackets{unreceived_packets:[]") + return len(response.Result.Src.UnreceivedPackets) != 0 } func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) { From 861479e72d28886f365a20b0c2fbd7c68c672e3a Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 9 Jun 2023 10:54:20 +0200 Subject: [PATCH 3/3] fix: rename response RelayerPacketsOutput --- tests/e2e/e2e_ibc_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/e2e_ibc_test.go b/tests/e2e/e2e_ibc_test.go index 5ecca234e0f..be6a1d2c3fc 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 } -type Response struct { +type RelayerPacketsOutput struct { Result struct { Dst struct { UnreceivedPackets []interface{} `json:"unreceived_packets"` @@ -134,12 +134,12 @@ func (s *IntegrationTestSuite) hermesPendingPackets(configPath, chainID, channel stdout, _ := s.executeHermesCommand(ctx, hermesCmd) - var response Response - err := json.Unmarshal(stdout, &response) + var relayerPacketsOutput RelayerPacketsOutput + err := json.Unmarshal(stdout, &relayerPacketsOutput) s.Require().NoError(err) // Check if "unreceived_packets" exists in "src" - return len(response.Result.Src.UnreceivedPackets) != 0 + return len(relayerPacketsOutput.Result.Src.UnreceivedPackets) != 0 } func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) {