-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[explorer/nodewatch] task: add new route #343
base: dev
Are you sure you want to change the base?
Conversation
14473d1
to
d655a86
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## dev #343 +/- ##
==========================================
- Coverage 98.91% 98.89% -0.02%
==========================================
Files 54 54
Lines 1850 1909 +59
Branches 72 72
==========================================
+ Hits 1830 1888 +58
- Misses 20 21 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
3f743cd
to
1310d05
Compare
1310d05
to
1832550
Compare
is_https_enable=None, | ||
is_wss_enable=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable => enabled (x2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we actually need BOTH of these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the explorer, we will need the is_https_enable
, for the wallet it needs is_wss_enable
.
Can we consider if https enable, we can assume wss is enable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we consider if https enable, we can assume wss is enable?
yes, i would.
cc: @gimre-xymcity
explorer/nodewatch/tests/test_app.py
Outdated
] == list(map(lambda descriptor: descriptor['name'], response_json)) | ||
|
||
|
||
def test_get_api_symbol_nodes(client): # pylint: disable=redefined-outer-name | ||
# Act: | ||
response = client.get('/api/symbol/nodes') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need a new /nodes route in addition to nodes/peer and nodes/api?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this as well, but not sure it's a good idea, here is my thought.
purpose
- the endpoint mainly returns all nodes and displays them on explorer.
- this endpoint added SSL, limit, and order filters, which will use to init explorer, and wallet to pull all healthy nodes.
calling 1 request instead of 2 to get all node lists.
But I didn't think that is the problem called 2 requests to get the node list, I can apply query params in the 2 endpoints as well.
what will you recommand?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can apply query params in the 2 endpoints as well
I think I would prefer this approach, but also ask @gimre-xymcity his opinion.
42f0d51
to
214790a
Compare
[2, 3], | ||
list(map(lambda descriptor: descriptor['roles'], node_descriptors))) | ||
|
||
def test_can_generate_nodes_json_filtered_order_random_limit_2(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also would rename to random_subset
@@ -361,15 +371,15 @@ def test_can_generate_nodes_json(self): | |||
facade.reload_all(Path('tests/resources'), True) | |||
|
|||
# Act: | |||
node_descriptors = facade.json_nodes(1) | |||
node_descriptors = facade.json_nodes(role=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on naming of test, this test should probably have no filter
list(map(lambda descriptor: descriptor['name'], node_descriptors))) | ||
self.assertEqual( | ||
[7, 3, 3, 5, 3], | ||
[7, 3, 3, 5, 3, 3, 3], | ||
list(map(lambda descriptor: descriptor['roles'], node_descriptors))) | ||
|
||
def test_can_generate_nodes_json_filtered(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would add _by_role to this test and next
self.assertEqual(2, len(node_descriptors)) | ||
for name in random_node_names: | ||
self.assertIn(name, full_node_names) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would add test with limit but without random
for name in random_node_names: | ||
self.assertIn(name, full_node_names) | ||
|
||
def test_can_generate_node_json_given_main_public_key(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider test names:
can_find_known_node_by_main_public_key
can_find_known_node_by_node_public_key
cannot_find_unknown_node_by_main_public_key
cannot_find_unknown_node_by_node_public_key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those names actually cause pylint error (name too long), but I'm ok with that name. so I used # pylint: disable=invalid-name
|
||
def custom_filter(descriptor): | ||
role_condition = True | ||
|
||
if role is not None: | ||
role_condition = role == descriptor.roles if exact_match else role == (role & descriptor.roles) | ||
|
||
if ssl is not None: | ||
if only_ssl is True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need "is True" ?
nodes = nodes[:limit] | ||
|
||
return nodes | ||
return nodes if limit == 0 else nodes[:limit] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not limit. ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is not the limit, it will set it to 0.
full_api_node_names = [ | ||
'Allnodes250', 'Allnodes251' | ||
] | ||
actual_names = list(map(lambda descriptor: descriptor['name'], response_json)) | ||
|
||
# Assert: | ||
_assert_symbol_node_response(response, actual_names) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert len(actual_names) == 1
@@ -232,9 +233,9 @@ def test_get_api_symbol_nodes_peer_order_random_limit_2(client): # pylint: disa | |||
assert name in full_node_names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert length of actual names is 2
@@ -226,7 +226,7 @@ def test_can_reload_all(self): | |||
self.assertEqual(True, result) | |||
self.assertEqual(facade.last_reload_time, facade.last_refresh_time) | |||
|
|||
self.assertEqual(6, len(facade.repository.node_descriptors)) | |||
self.assertEqual(9, len(facade.repository.node_descriptors)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding a comment
[2, 2, 7, 3, 3], | ||
list(map(lambda descriptor: descriptor['roles'], node_descriptors))) | ||
|
||
def can_find_known_node_by_main_public_key(self): # pylint: disable=invalid-name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test need to start with test_ prefix or they will not be detected as tests (x4)
nodes = nodes[:limit] | ||
|
||
return nodes | ||
return nodes if limit == 0 else nodes[:limit] | ||
|
||
def json_node(self, filter_field, public_key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might want to consider checking if public_key is proper public key and returning 400 if not
901e815
to
2ee1d0e
Compare
What was the issue?
What's the fix?
isHealthy, isHttpsEnable, isWssEnable, restVersion