Skip to content

Commit

Permalink
Merge pull request #39 from skalenetwork/bug/SKALE-2444-fix-status
Browse files Browse the repository at this point in the history
Bug/skale 2444 fix status
  • Loading branch information
DmytroNazarenko authored Apr 15, 2020
2 parents 22476e7 + dfe37a1 commit 1a9ef26
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
author='SKALE Labs',
author_email='[email protected]',
install_requires=[
"web3==5.2.2"
"web3==5.5.1"
],
packages=find_packages(exclude=['tests']),
python_requires='>=3.6,<4',
Expand Down
26 changes: 13 additions & 13 deletions sgx/ssl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ def sign_certificate(csr_server, csr_path):
def send_request(url, method, params, path_to_cert=None):
headers = {'content-type': 'application/json'}
call_data = {
"id": 0,
"jsonrpc": "2.0",
"method": method,
"params": params,
"jsonrpc": "2.0",
"id": 0,
}
print_request_log(method, params)
print_request_log(call_data)
if path_to_cert:
cert_provider = get_cert_provider(url)
response = requests.post(
Expand Down Expand Up @@ -115,10 +115,10 @@ def get_cert_provider(endpoint):
return url


def print_request_log(method, params):
cropped_params = copy.deepcopy(params)
crop_json(cropped_params)
logger.info(f'Send request: {method}, {cropped_params}')
def print_request_log(request):
cropped_request = copy.deepcopy(request)
crop_json(cropped_request)
logger.info(f'Send request: {request}')


def print_response_log(response):
Expand All @@ -127,10 +127,10 @@ def print_response_log(response):
logger.info(f'Response received: {cropped_response}')


def crop_json(d, crop_len=50):
for k, v in d.items():
if isinstance(v, dict):
crop_json(v)
def crop_json(json_data, crop_len=50):
for key, value in json_data.items():
if isinstance(value, dict):
crop_json(value)
else:
if isinstance(v, str) and len(v) > crop_len:
d[k] = v[:crop_len] + '...'
if isinstance(value, str) and len(value) > crop_len:
json_data[key] = value[:crop_len] + '...'
5 changes: 5 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ def get_info():
return account


def get_server_status():
assert sgx.get_server_status() == 0


if __name__ == '__main__':
print(sign_and_send())
print(get_info())
get_server_status()

0 comments on commit 1a9ef26

Please sign in to comment.