Skip to content

Commit

Permalink
Merge pull request #798 from skalenetwork/develop
Browse files Browse the repository at this point in the history
Fix schains ls (beta)
  • Loading branch information
DmytroNazarenko authored Nov 4, 2024
2 parents 833347f + c5978b1 commit 5c2414a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion node_cli/core/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def get_sgx_info():
['Server URL', data['sgx_server_url']],
['SGXWallet Version', data['sgx_wallet_version']],
['Node SGX keyname', data['sgx_keyname']],
['Status', data['status_name']]
['Status HTTPS', data['status_https']],
['Status ZMQ', data['status_zmq']]
]
table = SingleTable(table_data)
print(table.table)
Expand Down
8 changes: 5 additions & 3 deletions node_cli/utils/print_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,21 @@ def print_schains(schains):
'Deposit',
'Generation',
'Originator',
'Type',
]
rows = []
for schain in schains:
date = datetime.datetime.fromtimestamp(schain['startDate'])
date = datetime.datetime.fromtimestamp(schain['start_date'])
rows.append([
schain['name'],
schain['mainnetOwner'],
schain['partOfNode'],
schain['mainnet_owner'],
schain['part_of_node'],
schain['lifetime'],
format_date(date),
schain['deposit'],
schain['generation'],
schain['originator'],
schain['options']['allocation_type']
])
print(Formatter().table(headers, rows))

Expand Down
5 changes: 3 additions & 2 deletions tests/cli/health_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def test_sgx_status():
'sgx_server_url': 'https://127.0.0.1:1026',
'sgx_wallet_version': '1.50.1-stable.0',
'sgx_keyname': 'test_keyname',
'status_name': 'CONNECTED'
'status_zmq': True,
'status_https': True
}
resp_mock = response_mock(
requests.codes.ok,
Expand All @@ -97,4 +98,4 @@ def test_sgx_status():
'node_cli.utils.helper.requests.get', resp_mock, sgx)

assert result.exit_code == 0
assert result.output == '\x1b(0lqqqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqqqk\x1b(B\n\x1b(0x\x1b(B SGX info \x1b(0x\x1b(B \x1b(0x\x1b(B\n\x1b(0tqqqqqqqqqqqqqqqqqqqnqqqqqqqqqqqqqqqqqqqqqqqqu\x1b(B\n\x1b(0x\x1b(B Server URL \x1b(0x\x1b(B https://127.0.0.1:1026 \x1b(0x\x1b(B\n\x1b(0x\x1b(B SGXWallet Version \x1b(0x\x1b(B 1.50.1-stable.0 \x1b(0x\x1b(B\n\x1b(0x\x1b(B Node SGX keyname \x1b(0x\x1b(B test_keyname \x1b(0x\x1b(B\n\x1b(0x\x1b(B Status \x1b(0x\x1b(B CONNECTED \x1b(0x\x1b(B\n\x1b(0mqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqqj\x1b(B\n' # noqa
assert result.output == '\x1b(0lqqqqqqqqqqqqqqqqqqqwqqqqqqqqqqqqqqqqqqqqqqqqk\x1b(B\n\x1b(0x\x1b(B SGX info \x1b(0x\x1b(B \x1b(0x\x1b(B\n\x1b(0tqqqqqqqqqqqqqqqqqqqnqqqqqqqqqqqqqqqqqqqqqqqqu\x1b(B\n\x1b(0x\x1b(B Server URL \x1b(0x\x1b(B https://127.0.0.1:1026 \x1b(0x\x1b(B\n\x1b(0x\x1b(B SGXWallet Version \x1b(0x\x1b(B 1.50.1-stable.0 \x1b(0x\x1b(B\n\x1b(0x\x1b(B Node SGX keyname \x1b(0x\x1b(B test_keyname \x1b(0x\x1b(B\n\x1b(0x\x1b(B Status HTTPS \x1b(0x\x1b(B True \x1b(0x\x1b(B\n\x1b(0x\x1b(B Status ZMQ \x1b(0x\x1b(B True \x1b(0x\x1b(B\n\x1b(0mqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqqj\x1b(B\n' # noqa
18 changes: 9 additions & 9 deletions tests/cli/schains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def test_ls():
time.tzset()
payload = [
{
'name': 'test_schain1', 'mainnetOwner': '0x123',
'indexInOwnerList': 3, 'partOfNode': 0,
'lifetime': 5, 'startDate': 1570115385,
'deposit': 1000000000000000000, 'index': 3, 'generation': 1, 'originator': '0x465'
'name': 'test_schain1', 'mainnet_owner': '0x123',
'index_owner_list': 3, 'part_of_node': 0,
'lifetime': 5, 'start_date': 1570115385,
'deposit': 1000000000000000000, 'index': 3, 'generation': 1, 'originator': '0x465', 'options': {'allocation_type': 0} # noqa
},
{
'name': 'crazy_cats1',
'mainnetOwner': '0x321',
'indexInOwnerList': 8, 'partOfNode': 0,
'lifetime': 5, 'startDate': 1570469410,
'deposit': 1000000000000000000, 'index': 8, 'generation': 0, 'originator': '0x0'
'mainnet_owner': '0x321',
'index_owner_list': 8, 'part_of_node': 0,
'lifetime': 5, 'start_date': 1570469410,
'deposit': 1000000000000000000, 'index': 8, 'generation': 0, 'originator': '0x0', 'options': {'allocation_type': 0} # noqa
}
]
resp_mock = response_mock(
Expand All @@ -52,7 +52,7 @@ def test_ls():
)
result = run_command_mock('node_cli.utils.helper.requests.get', resp_mock, ls)
assert result.exit_code == 0
assert result.output == ' Name Owner Size Lifetime Created At Deposit Generation Originator\n-------------------------------------------------------------------------------------------------------------\ntest_schain1 0x123 0 5 Oct 03 2019 16:09:45 1000000000000000000 1 0x465 \ncrazy_cats1 0x321 0 5 Oct 07 2019 18:30:10 1000000000000000000 0 0x0 \n' # noqa
assert result.output == ' Name Owner Size Lifetime Created At Deposit Generation Originator Type\n--------------------------------------------------------------------------------------------------------------------\ntest_schain1 0x123 0 5 Oct 03 2019 16:09:45 1000000000000000000 1 0x465 0 \ncrazy_cats1 0x321 0 5 Oct 07 2019 18:30:10 1000000000000000000 0 0x0 0 \n' # noqa


def test_dkg():
Expand Down

0 comments on commit 5c2414a

Please sign in to comment.