Skip to content

Commit

Permalink
Merge branch 'main' into dk/self-audit
Browse files Browse the repository at this point in the history
  • Loading branch information
makramkd authored Nov 1, 2024
2 parents c1c5bd2 + d88cf46 commit ea52c98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
4 changes: 0 additions & 4 deletions pkg/reader/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -1397,10 +1397,6 @@ func (r *ccipChainReader) GetMedianDataAvailabilityGasConfig(
}
}

if len(overheadGasValues) == 0 {
return cciptypes.DataAvailabilityGasConfig{}, fmt.Errorf("no valid fee quoter destChainConfigs found")
}

// Calculate medians
medianOverheadGas := consensus.Median(overheadGasValues, func(a, b uint32) bool { return a < b })
medianGasPerByte := consensus.Median(gasPerByteValues, func(a, b uint16) bool { return a < b })
Expand Down
44 changes: 21 additions & 23 deletions pkg/reader/ccip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1007,23 +1007,6 @@ func TestCCIPChainReader_GetMedianDataAvailabilityGasConfig(t *testing.T) {
}
}

setupErrorMocks := func(
readers map[cciptypes.ChainSelector]*reader_mocks.MockExtended,
chains []cciptypes.ChainSelector, err error) {
for _, chain := range chains {
readers[chain].EXPECT().
ExtendedGetLatestValue(
mock.Anything,
consts.ContractNameFeeQuoter,
consts.MethodNameGetDestChainConfig,
primitives.Unconfirmed,
mock.Anything,
mock.Anything,
).
Return(err).Once()
}
}

tests := []struct {
name string
expectedConfig cciptypes.DataAvailabilityGasConfig
Expand Down Expand Up @@ -1066,17 +1049,32 @@ func TestCCIPChainReader_GetMedianDataAvailabilityGasConfig(t *testing.T) {
},
},
{
name: "error - no valid configs found",
expectError: true,
name: "no valid configs found due to empty DA params",
expectedConfig: cciptypes.DataAvailabilityGasConfig{
DestDataAvailabilityOverheadGas: 0,
DestGasPerDataAvailabilityByte: 0,
DestDataAvailabilityMultiplierBps: 0,
},
expectError: false,
chains: []cciptypes.ChainSelector{chainA, chainB, chainC},
setupMocks: func(readers map[cciptypes.ChainSelector]*reader_mocks.MockExtended) {
setupErrorMocks(readers, []cciptypes.ChainSelector{chainA, chainB, chainC}, errors.New("mock error"))
values := []mockValue{
{0, 0, 0, true}, // Empty DA params
{0, 0, 0, true}, // Empty DA params
{0, 0, 0, true}, // Empty DA params
}
setupConfigMocks(readers, []cciptypes.ChainSelector{chainA, chainB, chainC}, values)
},
},
{
name: "error - all configs disabled",
expectError: true,
chains: []cciptypes.ChainSelector{chainA, chainB},
name: "all configs disabled",
expectError: false,
expectedConfig: cciptypes.DataAvailabilityGasConfig{
DestDataAvailabilityOverheadGas: 0,
DestGasPerDataAvailabilityByte: 0,
DestDataAvailabilityMultiplierBps: 0,
},
chains: []cciptypes.ChainSelector{chainA, chainB},
setupMocks: func(readers map[cciptypes.ChainSelector]*reader_mocks.MockExtended) {
values := []mockValue{
{100, 10, 1000, false},
Expand Down

0 comments on commit ea52c98

Please sign in to comment.