From 982c296725577c7afbca7276cbe3909a0c927ae1 Mon Sep 17 00:00:00 2001 From: badrogger Date: Fri, 1 Nov 2024 17:15:05 +0000 Subject: [PATCH 1/2] Fix schains formatter --- node_cli/utils/print_formatters.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/node_cli/utils/print_formatters.py b/node_cli/utils/print_formatters.py index 4f0fdc7a..72225db9 100644 --- a/node_cli/utils/print_formatters.py +++ b/node_cli/utils/print_formatters.py @@ -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)) From 60bdad041b03b4dec41af1def28cb5683280c572 Mon Sep 17 00:00:00 2001 From: badrogger Date: Fri, 1 Nov 2024 19:10:14 +0000 Subject: [PATCH 2/2] Fix tests --- node_cli/core/health.py | 3 ++- tests/cli/health_test.py | 5 +++-- tests/cli/schains_test.py | 18 +++++++++--------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/node_cli/core/health.py b/node_cli/core/health.py index 623c20d7..247831db 100644 --- a/node_cli/core/health.py +++ b/node_cli/core/health.py @@ -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) diff --git a/tests/cli/health_test.py b/tests/cli/health_test.py index f34433df..b2f2fa3f 100644 --- a/tests/cli/health_test.py +++ b/tests/cli/health_test.py @@ -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, @@ -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 diff --git a/tests/cli/schains_test.py b/tests/cli/schains_test.py index 3126976a..d12e7277 100644 --- a/tests/cli/schains_test.py +++ b/tests/cli/schains_test.py @@ -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( @@ -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():