Skip to content

Commit

Permalink
fixed panic in Test_CLOSpecApprovalFlow_dynamicPriceGetter
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhuie19 committed Sep 15, 2024
1 parent 261d655 commit adac213
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (d *DynamicPriceGetter) performBatchCall(ctx context.Context, chainID uint6
},
{
ReadName: latestRoundDataMethodName,
ReturnVal: latestRoundData,
ReturnVal: &latestRoundData,
},
},
})
Expand All @@ -210,21 +210,35 @@ func (d *DynamicPriceGetter) performBatchCall(ctx context.Context, chainID uint6

// Extract results
// give result the method key and then you get slice of responses
decimalRespSlice := result[decimalsMethodName]
offchainAggregatorRespSlice := result["OffchainAggregator"]
decimalsCR := make([]uint8, 0, nbDecimalCalls)
latestRoundCR := make([]latestRoundDataConfig, 0, nbDecimalCalls)
var respErr error
for i, read := range decimalRespSlice {
for i, read := range offchainAggregatorRespSlice {
val, readErr := read.GetResult()
if readErr != nil {
respErr = multierr.Append(respErr, fmt.Errorf("error with method call %v: %w", batchCalls.decimalCalls[i].MethodName(), readErr))
continue
}
decimal, ok := val.(uint8)
if !ok {
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[i].MethodName(), batchCalls.decimalCalls[i].ContractAddress(), readErr)
if read.ReadName == decimalsMethodName {
decimal, ok := val.(uint8)
if !ok {
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[i].MethodName(), batchCalls.decimalCalls[i].ContractAddress(), readErr)
}

decimalsCR = append(decimalsCR, decimal)
} else if read.ReadName == latestRoundDataMethodName {
latestRoundDataRes, ok := val.(latestRoundDataConfig)
if !ok {
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[i].MethodName(), batchCalls.decimalCalls[i].ContractAddress(), readErr)
}

latestRoundCR = append(latestRoundCR, latestRoundDataRes)

Check failure on line 236 in core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go

View workflow job for this annotation

GitHub Actions / lint

SA4010: this result of append is never used, except maybe in other appends (staticcheck)
}

decimalsCR = append(decimalsCR, decimal)
}

Check failure on line 239 in core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)
if respErr != nil {
return respErr
}

// Perform batched call (all decimals calls followed by latest round data calls).
Expand Down

0 comments on commit adac213

Please sign in to comment.