diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go index db0a2bd249..e7aac86033 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go @@ -164,7 +164,7 @@ func NewUSDCTokenDataReaderWithHttpClient( // attestation response. When called back to back, or multiple times // concurrently, responses are delayed according how the request interval is // configured. -func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta, tokenIndex int) (messageAndAttestation []byte, err error) { +func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2EVMOnRampCCIPSendRequestedWithMeta, tokenIndex int) ([]byte, error) { if tokenIndex < 0 || tokenIndex >= len(msg.TokenAmounts) { return nil, fmt.Errorf("token index out of bounds") } @@ -177,7 +177,7 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E if s.rate != nil { // Wait blocks until it the attestation API can be called or the // context is Done. - if waitErr := s.rate.Wait(ctx); err != nil { + if waitErr := s.rate.Wait(ctx); waitErr != nil { return nil, fmt.Errorf("usdc rate limiting error: %w", waitErr) } } @@ -197,7 +197,7 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E switch attestationResp.Status { case attestationStatusSuccess: // The USDC pool needs a combination of the message body and the attestation - messageAndAttestation, err = encodeMessageAndAttestation(messageBody, attestationResp.Attestation) + messageAndAttestation, err := encodeMessageAndAttestation(messageBody, attestationResp.Attestation) if err != nil { return nil, fmt.Errorf("failed to encode messageAndAttestation : %w", err) } diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go index 1247f8dd20..c4221b2dc0 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go @@ -335,7 +335,7 @@ func TestUSDCReader_rateLimiting(t *testing.T) { rateConfig: 100 * time.Millisecond, testDuration: 1 * time.Millisecond, timeout: 1 * time.Millisecond, - err: "usdc rate limiting error: rate: Wait(n=1) would exceed context deadline", + err: "usdc rate limiting error:", }, { name: "timeout after second request", @@ -343,7 +343,7 @@ func TestUSDCReader_rateLimiting(t *testing.T) { rateConfig: 100 * time.Millisecond, testDuration: 100 * time.Millisecond, timeout: 150 * time.Millisecond, - err: "usdc rate limiting error: rate: Wait(n=1) would exceed context deadline", + err: "usdc rate limiting error:", }, } @@ -405,7 +405,7 @@ func TestUSDCReader_rateLimiting(t *testing.T) { // Collect errors errorFound := false for err := range errorChan { - if tc.err != "" && !strings.Contains(err.Error(), tc.err) { + if tc.err != "" && strings.Contains(err.Error(), tc.err) { errorFound = true } else if err != nil && !strings.Contains(err.Error(), "get usdc token 0 end offset") { // Ignore that one error, it's expected because of how mocking is used. @@ -413,6 +413,7 @@ func TestUSDCReader_rateLimiting(t *testing.T) { require.Fail(t, "unexpected error", err) } } + if tc.err != "" { assert.True(t, errorFound) }