File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,8 @@ def connect(self):
114114 # Check for empty response
115115 if req .text :
116116 data = req .json ()
117- if data .get ('status' ) == '1' or 'result' in data :
117+ status = data .get ('status' )
118+ if status == '1' or self .check_keys_api (data ):
118119 return data
119120 else :
120121 raise EmptyResponse (data .get ('message' , 'no message' ))
@@ -125,3 +126,7 @@ def check_and_get_api(self):
125126 pass
126127 else :
127128 self .url_dict [self .API_KEY ] = input ('Please type your EtherScan.io API key: ' )
129+
130+ def check_keys_api (self , data ):
131+ return all (k in data for k in ('jsonrpc' , 'id' , 'result' ))
132+
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ def test_get_most_recent_block(self):
1313 api = Proxies (api_key = API_KEY )
1414 # currently raises an exception even though it should not, see:
1515 # https://github.com/corpetty/py-etherscan-api/issues/32
16- with self . assertRaises ( EmptyResponse ):
17- most_recent = int ( api . get_most_recent_block (), 16 )
18- print ( most_recent )
19- p = re . compile ( '^[0-9]{7}$' )
20- self . assertTrue ( p . match ( str ( most_recent )))
16+ most_recent = int ( api . get_most_recent_block (), 16 )
17+ print ( most_recent )
18+ p = re . compile ( '^[0-9]{7}$' )
19+ self . assertTrue ( p . match ( str ( most_recent )) )
20+
You can’t perform that action at this time.
0 commit comments