Skip to content

Commit 06f7b04

Browse files
committed
Correcting test failures
1 parent 88d2f06 commit 06f7b04

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

etherscan/client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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+

tests/test_proxies.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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+

0 commit comments

Comments
 (0)