diff --git a/pkg/clients/ethereum/client.go b/pkg/clients/ethereum/client.go index b49f9a3e..b09e0095 100644 --- a/pkg/clients/ethereum/client.go +++ b/pkg/clients/ethereum/client.go @@ -96,13 +96,10 @@ func DefaultChunkedCallEthereumClientConfig() *EthereumClientConfig { } } -func NewClient(cfg *EthereumClientConfig, l *zap.Logger, hc ...*http.Client) *Client { +func NewClient(cfg *EthereumClientConfig, l *zap.Logger) *Client { client := &http.Client{ Timeout: time.Second * 10, } - if len(hc) > 0 && hc[0] != nil { - client = hc[0] - } l.Sugar().Infow("Creating new Ethereum client", zap.Any("config", cfg)) @@ -113,6 +110,10 @@ func NewClient(cfg *EthereumClientConfig, l *zap.Logger, hc ...*http.Client) *Cl } } +func (c *Client) SetHttpClient(client *http.Client) { + c.httpClient = client +} + func (c *Client) GetEthereumContractCaller() (*ethclient.Client, error) { d, err := ethclient.Dial(c.clientConfig.BaseUrl) if err != nil { diff --git a/pkg/contractManager/contractManager_test.go b/pkg/contractManager/contractManager_test.go index 3e5d0854..191c41f8 100644 --- a/pkg/contractManager/contractManager_test.go +++ b/pkg/contractManager/contractManager_test.go @@ -71,7 +71,8 @@ func Test_ContractManager(t *testing.T) { ethConfig := ethereum.DefaultNativeCallEthereumClientConfig() ethConfig.BaseUrl = baseUrl - client := ethereum.NewClient(ethConfig, l, mockHttpClient) + client := ethereum.NewClient(ethConfig, l) + client.SetHttpClient(mockHttpClient) af := abiFetcher.NewAbiFetcher(client, &http.Client{Timeout: 5 * time.Second}, l, cfg)