Skip to content

Commit

Permalink
test: parsing result of query hermes pending packets (#2571)
Browse files Browse the repository at this point in the history
* fix: e2e test

* fix: parsing hermes pending packet query result

* fix: rename response RelayerPacketsOutput
  • Loading branch information
yaruwangway authored and sainoe committed Jun 23, 2023
1 parent e945ec5 commit eb9c9e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/e2e_exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ package e2e
// }
// }

// 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
Expand All @@ -642,7 +642,7 @@ package e2e
// 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 {
Expand Down
27 changes: 21 additions & 6 deletions tests/e2e/e2e_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ package e2e
// }

// 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()

Expand All @@ -98,18 +98,31 @@ package e2e
// }

// 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 RelayerPacketsOutput 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",
Expand All @@ -120,11 +133,13 @@ package e2e
// }

// stdout, _ := s.executeHermesCommand(ctx, hermesCmd)
// stdout = strings.ReplaceAll(stdout, " ", "")
// stdout = strings.ReplaceAll(stdout, "\n", "")

// var relayerPacketsOutput RelayerPacketsOutput
// err := json.Unmarshal(stdout, &relayerPacketsOutput)
// s.Require().NoError(err)

// // Check if "unreceived_packets" exists in "src"
// return !strings.Contains(stdout, "src:pendingPackets{unreceived_packets:[]")
// return len(relayerPacketsOutput.Result.Src.UnreceivedPackets) != 0
// }

// func (s *IntegrationTestSuite) queryRelayerWalletsBalances() (sdk.Coin, sdk.Coin) {
Expand Down

0 comments on commit eb9c9e5

Please sign in to comment.