Skip to content

Commit

Permalink
review fixes:
Browse files Browse the repository at this point in the history
- typo
- using encoding.ErrCodeNil instead of 0
- rename ErrCodeMercuryError -> ErrCodeDataStreamsError
  • Loading branch information
amirylm committed Feb 15, 2024
1 parent dcacbdc commit 16f0b14
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type ErrCode uint32

const (
ErrCodeNil ErrCode = 0
ErrCodePartielContent ErrCode = 800206
ErrCodeMercuryError ErrCode = 808500
ErrCodePartialContent ErrCode = 800206
ErrCodeDataStreamsError ErrCode = 808500
ErrCodeBadRequest ErrCode = 800400
ErrCodeUnauthorized ErrCode = 800401
ErrCodeEncodingError ErrCode = 808600
Expand All @@ -63,13 +63,13 @@ func HttpToErrCode(statusCode int) ErrCode {
case http.StatusOK:
return ErrCodeNil
case http.StatusPartialContent:
return ErrCodePartielContent
return ErrCodePartialContent
case http.StatusBadRequest:
return ErrCodeBadRequest
case http.StatusUnauthorized:
return ErrCodeUnauthorized
case http.StatusInternalServerError, http.StatusBadGateway, http.StatusServiceUnavailable, http.StatusGatewayTimeout:
return ErrCodeMercuryError
return ErrCodeDataStreamsError
default:
return 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *client) DoRequest(ctx context.Context, streamsLookup *mercury.StreamsLo
resultLen := len(streamsLookup.Feeds)
ch := make(chan mercury.MercuryData, resultLen)
if len(streamsLookup.Feeds) == 0 {
return encoding.NoPipelineError, encoding.UpkeepFailureReasonInvalidRevertDataInput, [][]byte{}, false, 0 * time.Second, 0, fmt.Errorf("invalid revert data input: feed param key %s, time param key %s, feeds %s", streamsLookup.FeedParamKey, streamsLookup.TimeParamKey, streamsLookup.Feeds)
return encoding.NoPipelineError, encoding.UpkeepFailureReasonInvalidRevertDataInput, [][]byte{}, false, 0 * time.Second, encoding.ErrCodeNil, fmt.Errorf("invalid revert data input: feed param key %s, time param key %s, feeds %s", streamsLookup.FeedParamKey, streamsLookup.TimeParamKey, streamsLookup.Feeds)
}
for i := range streamsLookup.Feeds {
// TODO (AUTO-7209): limit the number of concurrent requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func TestV02_DoMercuryRequestV02(t *testing.T) {
expectedRetryable: true,
pluginRetries: 0,
expectedRetryInterval: 1 * time.Second,
expectedErrCode: encoding.ErrCodeMercuryError,
expectedErrCode: encoding.ErrCodeDataStreamsError,
expectedError: errors.New("failed to request feed for 0x4554482d5553442d415242495452554d2d544553544e45540000000000000000: All attempts fail:\n#1: 500\n#2: 500\n#3: 500"),
state: encoding.MercuryFlakyFailure,
},
Expand All @@ -353,7 +353,7 @@ func TestV02_DoMercuryRequestV02(t *testing.T) {
expectedValues: [][]byte{nil},
expectedRetryable: true,
expectedRetryInterval: 5 * time.Second,
expectedErrCode: encoding.ErrCodeMercuryError,
expectedErrCode: encoding.ErrCodeDataStreamsError,
expectedError: errors.New("failed to request feed for 0x4554482d5553442d415242495452554d2d544553544e45540000000000000000: All attempts fail:\n#1: 500\n#2: 500\n#3: 500"),
state: encoding.MercuryFlakyFailure,
},
Expand All @@ -374,7 +374,7 @@ func TestV02_DoMercuryRequestV02(t *testing.T) {
mockChainlinkBlobs: []string{"0x00066dfcd1ed2d95b18c948dbc5bd64c687afe93e4ca7d663ddec14c20090ad80000000000000000000000000000000000000000000000000000000000081401000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000280000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001204554482d5553442d415242495452554d2d544553544e455400000000000000000000000000000000000000000000000000000000000000000000000064891c98000000000000000000000000000000000000000000000000000000289ad8d367000000000000000000000000000000000000000000000000000000289acf0b38000000000000000000000000000000000000000000000000000000289b3da40000000000000000000000000000000000000000000000000000000000018ae7ce74d9fa252a8983976eab600dc7590c778d04813430841bc6e765c34cd81a168d00000000000000000000000000000000000000000000000000000000018ae7cb0000000000000000000000000000000000000000000000000000000064891c98000000000000000000000000000000000000000000000000000000000000000260412b94e525ca6cedc9f544fd86f77606d52fe731a5d069dbe836a8bfc0fb8c911963b0ae7a14971f3b4621bffb802ef0605392b9a6c89c7fab1df8633a5ade00000000000000000000000000000000000000000000000000000000000000024500c2f521f83fba5efc2bf3effaaedde43d0a4adff785c1213b712a3aed0d8157642a84324db0cf9695ebd27708d4608eb0337e0dd87b0e43f0fa70c700d911"},
expectedValues: [][]byte{nil},
expectedRetryInterval: mercury.RetryIntervalTimeout,
expectedErrCode: encoding.ErrCodeMercuryError,
expectedErrCode: encoding.ErrCodeDataStreamsError,
expectedRetryable: true,
expectedError: errors.New("failed to request feed for 0x4554482d5553442d415242495452554d2d544553544e45540000000000000000: All attempts fail:\n#1: 500\n#2: 500\n#3: 500"),
state: encoding.MercuryFlakyFailure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewClient(mercuryConfig mercury.MercuryConfigProvider, httpClient mercury.H

func (c *client) DoRequest(ctx context.Context, streamsLookup *mercury.StreamsLookup, pluginRetryKey string) (encoding.PipelineExecutionState, encoding.UpkeepFailureReason, [][]byte, bool, time.Duration, encoding.ErrCode, error) {
if len(streamsLookup.Feeds) == 0 {
return encoding.NoPipelineError, encoding.UpkeepFailureReasonInvalidRevertDataInput, [][]byte{}, false, 0 * time.Second, 0, fmt.Errorf("invalid revert data input: feed param key %s, time param key %s, feeds %s", streamsLookup.FeedParamKey, streamsLookup.TimeParamKey, streamsLookup.Feeds)
return encoding.NoPipelineError, encoding.UpkeepFailureReasonInvalidRevertDataInput, [][]byte{}, false, 0 * time.Second, encoding.ErrCodeNil, fmt.Errorf("invalid revert data input: feed param key %s, time param key %s, feeds %s", streamsLookup.FeedParamKey, streamsLookup.TimeParamKey, streamsLookup.Feeds)
}
resultLen := 1 // Only 1 multi-feed request is made for all feeds
ch := make(chan mercury.MercuryData, resultLen)
Expand Down

0 comments on commit 16f0b14

Please sign in to comment.