diff --git a/etherscan/etherscan.go b/etherscan/etherscan.go index 13086b4a..562c1365 100644 --- a/etherscan/etherscan.go +++ b/etherscan/etherscan.go @@ -42,7 +42,7 @@ func NewEtherscanFromNetwork(n ethgo.Network, apiKey string) (*Etherscan, error) // NewEtherscan creates a new Etherscan service from a url func NewEtherscan(url, apiKey string) *Etherscan { - return &Etherscan{url: url} + return &Etherscan{url: url, apiKey: apiKey} } type proxyResponse struct { diff --git a/etherscan/etherscan_test.go b/etherscan/etherscan_test.go index fa5c1e09..7147abef 100644 --- a/etherscan/etherscan_test.go +++ b/etherscan/etherscan_test.go @@ -16,6 +16,14 @@ func testEtherscanMainnet(t *testing.T) *Etherscan { return &Etherscan{url: "https://api.etherscan.io", apiKey: apiKey} } +func TestNewEtherscan(t *testing.T) { + wantUrl := "http://test.url/" + wantApiKey := "abc123" + e := NewEtherscan(wantUrl, wantApiKey) + assert.Equal(t, wantUrl, e.url) + assert.Equal(t, wantApiKey, e.apiKey) +} + func TestBlockByNumber(t *testing.T) { e := testEtherscanMainnet(t) n, err := e.BlockNumber()