-
Notifications
You must be signed in to change notification settings - Fork 378
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
Split some essential MatrixTransport functions into independent utils #3393
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3393 +/- ##
=========================================
- Coverage 75.92% 75.82% -0.1%
=========================================
Files 97 100 +3
Lines 12565 12849 +284
Branches 1760 1819 +59
=========================================
+ Hits 9540 9743 +203
- Misses 2396 2462 +66
- Partials 629 644 +15
Continue to review full report at Codecov.
|
Thank you Andre! |
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.
Some comments below, otherwise looks good.
@@ -1370,7 +1215,8 @@ def _set_room_id_for_address(self, address: Address, room_id: Optional[_RoomID] | |||
|
|||
with self._account_data_lock: | |||
# no need to deepcopy, we don't modify lists in-place | |||
_address_to_room_ids: Dict[AddressHex, List[_RoomID]] = self._client.account_data.get( | |||
# type: Dict[AddressHex, List[_RoomID]] | |||
_address_to_room_ids = self._client.account_data.get( |
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.
Why use the old comment style type annotation here?
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.
It's in the commit description: mypy complained about the generic data coming from GMatrixClient
: account_data: Dict[str, Any]
incompatible with specified type, so I had to take out the type annotations here
@@ -1432,11 +1278,12 @@ def _get_room_ids_for_address( | |||
|
|||
return room_ids | |||
|
|||
def _leave_unused_rooms(self, _address_to_room_ids: Dict[AddressHex, List[_RoomID]]): | |||
def _leave_unused_rooms(self, _address_to_room_ids): |
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.
Why remove the annotation?
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.
Same from above comment
This list is used to possibly multiple global rooms (like 'discovery' and 'monitoring'). They're prefixed with 'raiden_<network_name>_'
Added unit test for matrix, others will join soon
Account_data is just a dict, mypy doesn't know how to interpret its types, so we remove them to a comment Also, added another test to validate_userid_signature
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.
Ok this is gtg from my perspective. I do want to wait a bit for the scenarios to run a bit longer to make sure this doesn't accidentally re-introduce some issue.
One other thing we didn't think about is extracting the server selection mechanism. But we can do that in a separate PR.
@@ -1370,7 +1205,8 @@ def _set_room_id_for_address(self, address: Address, room_id: Optional[_RoomID] | |||
|
|||
with self._account_data_lock: | |||
# no need to deepcopy, we don't modify lists in-place | |||
_address_to_room_ids: Dict[AddressHex, List[_RoomID]] = self._client.account_data.get( | |||
# type: Dict[AddressHex, List[_RoomID]] |
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.
Still don't really like this. We should look if there is a way to 'explain' things to mypy. But we can do that later.
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.
join_global_room
(fromjoin_discovery_room
)login_or_register
(withSigner
)validate_userid_signature
This PR makes these standalone functions, which depends only on
GMatrixClient
(now also pulled in fromraiden-libs
) and utils (like Signer), instead ofRaidenService
and other core classes instances (which was the case for theMatrixTransport
, to be decoupled on #3252).This also adds unit tests for these functions, as part of #3124
These functions should be enough to write a client capable of interacting with Raiden's MatrixTransport network, thus closes #3291