Skip to content

Commit 83a8d6e

Browse files
committed
Add SuggestGasTipCap to test client implementation
SuggestGasTipCap was added to ethereum client in ethereum/go-ethereum@7a7abe3 We need to include it in client interface implementation we use in tests.
1 parent fde9f18 commit 83a8d6e

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

pkg/chain/ethereum/ethutil/rate_limiter.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package ethutil
33
import (
44
"context"
55
"fmt"
6+
"math/big"
7+
68
"github.com/ethereum/go-ethereum"
79
"github.com/ethereum/go-ethereum/common"
810
"github.com/ethereum/go-ethereum/core/types"
911
"github.com/keep-network/keep-common/pkg/rate"
10-
"math/big"
1112
)
1213

1314
type rateLimiter struct {
@@ -96,6 +97,18 @@ func (rl *rateLimiter) SuggestGasPrice(
9697
return rl.EthereumClient.SuggestGasPrice(ctx)
9798
}
9899

100+
func (rl *rateLimiter) SuggestGasTipCap(
101+
ctx context.Context,
102+
) (*big.Int, error) {
103+
err := rl.Limiter.AcquirePermit()
104+
if err != nil {
105+
return nil, fmt.Errorf("cannot acquire rate limiter permit: [%v]", err)
106+
}
107+
defer rl.Limiter.ReleasePermit()
108+
109+
return rl.EthereumClient.SuggestGasTipCap(ctx)
110+
}
111+
99112
func (rl *rateLimiter) EstimateGas(
100113
ctx context.Context,
101114
call ethereum.CallMsg,

pkg/chain/ethereum/ethutil/rate_limiter_test.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ package ethutil
22

33
import (
44
"context"
5-
"github.com/ethereum/go-ethereum"
6-
"github.com/ethereum/go-ethereum/common"
7-
"github.com/ethereum/go-ethereum/core/types"
8-
"github.com/keep-network/keep-common/pkg/rate"
95
"math/big"
106
"strings"
117
"sync"
128
"testing"
139
"time"
10+
11+
"github.com/ethereum/go-ethereum"
12+
"github.com/ethereum/go-ethereum/common"
13+
"github.com/ethereum/go-ethereum/core/types"
14+
"github.com/keep-network/keep-common/pkg/rate"
1415
)
1516

1617
func TestRateLimiter(t *testing.T) {
@@ -365,6 +366,13 @@ func (mec *mockEthereumClient) SuggestGasPrice(
365366
return nil, nil
366367
}
367368

369+
func (mec *mockEthereumClient) SuggestGasTipCap(
370+
ctx context.Context,
371+
) (*big.Int, error) {
372+
mec.mockRequest()
373+
return nil, nil
374+
}
375+
368376
func (mec *mockEthereumClient) EstimateGas(
369377
ctx context.Context,
370378
call ethereum.CallMsg,
@@ -530,6 +538,14 @@ func getTests(
530538
return err
531539
},
532540
},
541+
"test SuggestGasTipCap": {
542+
function: func() error {
543+
_, err := client.SuggestGasTipCap(
544+
context.Background(),
545+
)
546+
return err
547+
},
548+
},
533549
"test EstimateGas": {
534550
function: func() error {
535551
_, err := client.EstimateGas(

0 commit comments

Comments
 (0)