File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 8
8
package etherscan
9
9
10
10
import (
11
+ "fmt"
12
+ "os"
11
13
"testing"
12
14
"time"
13
15
)
14
16
17
+ const apiKeyEnvName = "ETHERSCAN_API_KEY"
18
+
15
19
var (
16
20
// api test client for many test cases
17
21
api * Client
18
22
// bucket default rate limiter
19
23
bucket * Bucket
24
+ // apiKey etherscan API key
25
+ apiKey string
20
26
)
21
27
22
28
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
+ }
23
33
bucket = NewBucket (200 * time .Millisecond )
24
34
25
- api = New (Mainnet , "etherscan-api-e2e-test" )
35
+ api = New (Mainnet , apiKey )
26
36
api .Verbose = true
27
37
api .BeforeRequest = func (module string , action string , param map [string ]interface {}) error {
28
38
bucket .Take ()
You can’t perform that action at this time.
0 commit comments