6
6
7
7
from etherscan .etherscan import Etherscan
8
8
9
- CONFIG_PATH = "etherscan/configs/stable.json"
9
+ CONFIG_PATH = "etherscan/configs/{}- stable.json"
10
10
API_KEY = os .environ ["API_KEY" ] # Encrypted env var by Travis
11
11
12
12
@@ -22,18 +22,20 @@ def dump(data, fname):
22
22
23
23
class Case (TestCase ):
24
24
_MODULE = ""
25
+ _NETS = ["MAIN" , "GOERLI" , "KOVAN" , "RINKEBY" , "ROPSTEN" ]
25
26
26
- def test_methods (self ):
27
- print (f"\n MODULE: { self ._MODULE } " )
28
- config = load (CONFIG_PATH )
29
- etherscan = Etherscan (API_KEY )
27
+ def methods (self , net ):
28
+ print (f"\n NET: { net } " )
29
+ print (f"MODULE: { self ._MODULE } " )
30
+ config = load (CONFIG_PATH .format (net ))
31
+ etherscan = Etherscan (API_KEY , net )
30
32
for fun , v in config .items ():
31
33
if not fun .startswith ("_" ): # disabled if _
32
34
if v ["module" ] == self ._MODULE :
33
35
res = getattr (etherscan , fun )(** v ["kwargs" ])
34
36
print (f"METHOD: { fun } , RTYPE: { type (res )} " )
35
37
# Create log files (will update existing ones)
36
- fname = f"logs/standard/{ fun } .json"
38
+ fname = f"logs/standard/{ net } - { fun } .json"
37
39
log = {
38
40
"method" : fun ,
39
41
"module" : v ["module" ],
@@ -43,6 +45,10 @@ def test_methods(self):
43
45
}
44
46
dump (log , fname )
45
47
48
+ def test_net_methods (self ):
49
+ for net in self ._NETS :
50
+ self .methods (net )
51
+
46
52
47
53
class TestAccounts (Case ):
48
54
_MODULE = "accounts"
0 commit comments