Skip to content

Commit

Permalink
update err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Gololicic committed Oct 30, 2023
1 parent 385cf3d commit f1d8e39
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions integration/tests/access/access_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ func (s *AccessAPISuite) waitAccountsUntilIndexed(get getAccount) (*sdk.Account,
var err error
s.Require().Eventually(func() bool {
account, err = get()
statusErr, ok := status.FromError(err)
// make sure we either don't have an error or the error is not out of range error, since in that case we have to wait a bit longer for index to get synced
return err == nil || ok && statusErr.Code() != codes.OutOfRange
return notOutOfRangeError(err)
}, indexDelay, indexRetry)

return account, err
Expand All @@ -329,8 +327,7 @@ func (s *AccessAPISuite) waitScriptExecutionUntilIndexed(execute executeScript)
var err error
s.Require().Eventually(func() bool {
val, err = execute()
statusErr, ok := status.FromError(err)
return err == nil || ok && statusErr.Code() != codes.OutOfRange
return notOutOfRangeError(err)
}, indexDelay, indexRetry)

return val, err
Expand All @@ -348,3 +345,12 @@ func (s *AccessAPISuite) waitUntilIndexed(height uint64) {
return err == nil
}, 30*time.Second, 1*time.Second)
}

// make sure we either don't have an error or the error is not out of range error, since in that case we have to wait a bit longer for index to get synced
func notOutOfRangeError(err error) bool {
statusErr, ok := status.FromError(err)
if !ok || err == nil {
return true
}
return statusErr.Code() != codes.OutOfRange
}

0 comments on commit f1d8e39

Please sign in to comment.