Skip to content

Commit

Permalink
add mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
matYang committed Sep 13, 2023
1 parent 41f5bd4 commit 055aeb1
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 1 deletion.
129 changes: 129 additions & 0 deletions core/chains/evm/gas/chainoracles/mocks/l1_oracle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion core/chains/evm/gas/chainoracles/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (

// L1Oracle provides interface for fetching L1-specific fee components if the chain is an L2.
// For example, on Optimistic Rollups, this oracle can return rollup-specific l1BaseFee
//
//go:generate mockery --quiet --name L1Oracle --output ./mocks/ --case=underscore
type L1Oracle interface {
services.ServiceCtx

L1GasPrice(ctx context.Context) (*assets.Wei, error)
}
14 changes: 14 additions & 0 deletions core/chains/evm/gas/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/smartcontractkit/chainlink/v2/core/assets"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas"
oraclesMocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/chainoracles/mocks"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas/mocks"
)

Expand All @@ -36,6 +37,19 @@ func TestWrappedEvmEstimator(t *testing.T) {
e.On("BumpLegacyGas", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
Return(legacyFee, gasLimit, nil).Once()

// L1Oracle returns the correct L1Oracle interface
t.Run("L1Oracle", func(t *testing.T) {
// expect nil
estimator := gas.NewWrappedEvmEstimator(e, false)
l1Oracle := estimator.L1Oracle()
assert.Nil(t, l1Oracle)

o := oraclesMocks.NewL1Oracle(t)
estimator = gas.NewWrappedEvmEstimatorWithL1Oracle(e, false, o)
l1Oracle = estimator.L1Oracle()
assert.Equal(t, o, l1Oracle)
})

// GetFee returns gas estimation based on configuration value
t.Run("GetFee", func(t *testing.T) {
// expect legacy fee data
Expand Down

0 comments on commit 055aeb1

Please sign in to comment.