Skip to content

Commit

Permalink
Do not return the error in case if onRamp not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
valerii-kabisov-cll committed Oct 4, 2024
1 parent 4db2b21 commit d6b78b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions core/services/ocr2/plugins/ccip/estimatorconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package estimatorconfig

import (
"context"
"errors"
"math/big"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccip"
Expand Down Expand Up @@ -42,7 +41,7 @@ func (c *FeeEstimatorConfigService) SetOnRampReader(reader ccip.OnRampReader) {
// GetDynamicConfig should be cached in the onRamp reader to avoid unnecessary on-chain calls
func (c *FeeEstimatorConfigService) GetDataAvailabilityConfig(ctx context.Context) (destDataAvailabilityOverheadGas, destGasPerDataAvailabilityByte, destDataAvailabilityMultiplierBps int64, err error) {
if c.onRampReader == nil {
return 0, 0, 0, errors.New("no OnRampReader has been configured")
return 0, 0, 0, nil
}

cfg, err := c.onRampReader.GetDynamicConfig(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ func TestFeeEstimatorConfigService(t *testing.T) {
var expectedDestDataAvailabilityMultiplierBps int64 = 3

onRampReader := mocks.NewOnRampReader(t)
_, _, _, err := svc.GetDataAvailabilityConfig(ctx)
require.Error(t, err)
destDataAvailabilityOverheadGas, destGasPerDataAvailabilityByte, destDataAvailabilityMultiplierBps, err := svc.GetDataAvailabilityConfig(ctx)
require.NoError(t, err) // if onRampReader not set, return nil error and 0 values
require.EqualValues(t, 0, destDataAvailabilityOverheadGas)
require.EqualValues(t, 0, destGasPerDataAvailabilityByte)
require.EqualValues(t, 0, destDataAvailabilityMultiplierBps)
svc.SetOnRampReader(onRampReader)

onRampReader.On("GetDynamicConfig", ctx).
Expand All @@ -35,7 +38,7 @@ func TestFeeEstimatorConfigService(t *testing.T) {
DestDataAvailabilityMultiplierBps: uint16(expectedDestDataAvailabilityMultiplierBps),
}, nil).Once()

destDataAvailabilityOverheadGas, destGasPerDataAvailabilityByte, destDataAvailabilityMultiplierBps, err := svc.GetDataAvailabilityConfig(ctx)
destDataAvailabilityOverheadGas, destGasPerDataAvailabilityByte, destDataAvailabilityMultiplierBps, err = svc.GetDataAvailabilityConfig(ctx)
require.NoError(t, err)
require.Equal(t, expectedDestDataAvailabilityOverheadGas, destDataAvailabilityOverheadGas)
require.Equal(t, expectedDestGasPerDataAvailabilityByte, destGasPerDataAvailabilityByte)
Expand Down

0 comments on commit d6b78b8

Please sign in to comment.