Skip to content

Commit 42ada40

Browse files
committed
test: input etherscan API key through env
1 parent 84c69b5 commit 42ada40

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

setup_e2e_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,31 @@
88
package etherscan
99

1010
import (
11+
"fmt"
12+
"os"
1113
"testing"
1214
"time"
1315
)
1416

17+
const apiKeyEnvName = "ETHERSCAN_API_KEY"
18+
1519
var (
1620
// api test client for many test cases
1721
api *Client
1822
// bucket default rate limiter
1923
bucket *Bucket
24+
// apiKey etherscan API key
25+
apiKey string
2026
)
2127

2228
func init() {
29+
apiKey = os.Getenv(apiKeyEnvName)
30+
if apiKey == "" {
31+
panic(fmt.Sprintf("API key is empty, set env variable %q with a valid API key to proceed.", apiKeyEnvName))
32+
}
2333
bucket = NewBucket(200 * time.Millisecond)
2434

25-
api = New(Mainnet, "etherscan-api-e2e-test")
35+
api = New(Mainnet, apiKey)
2636
api.Verbose = true
2737
api.BeforeRequest = func(module string, action string, param map[string]interface{}) error {
2838
bucket.Take()

0 commit comments

Comments
 (0)