Skip to content
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

Merged
merged 12 commits into from
Feb 6, 2019
Merged

Split some essential MatrixTransport functions into independent utils #3393

merged 12 commits into from
Feb 6, 2019

Conversation

andrevmatos
Copy link
Contributor

  • join_global_room (from join_discovery_room)
  • login_or_register (with Signer)
  • validate_userid_signature

This PR makes these standalone functions, which depends only on GMatrixClient (now also pulled in from raiden-libs) and utils (like Signer), instead of RaidenService and other core classes instances (which was the case for the MatrixTransport, 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

@codecov-io
Copy link

codecov-io commented Feb 4, 2019

Codecov Report

Merging #3393 into master will decrease coverage by 0.09%.
The diff coverage is 71.95%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
raiden/app.py 90% <ø> (ø) ⬆️
raiden/network/transport/matrix/__init__.py 100% <100%> (ø)
raiden/network/transport/matrix/client.py 69.84% <69.84%> (ø)
raiden/network/transport/matrix/utils.py 73.33% <73.33%> (ø)
raiden/network/transport/matrix/transport.py 72.61% <84.61%> (ø)
raiden/transfer/mediated_transfer/events.py 83.17% <0%> (-0.94%) ⬇️
raiden/utils/upgrades.py 87.67% <0%> (-0.17%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed3216f...8657118. Read the comment docs.

@Dominik1999
Copy link
Contributor

Thank you Andre!

Copy link
Collaborator

@ulope ulope left a 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.

raiden/network/transport/matrix/__init__.py Outdated Show resolved Hide resolved
@@ -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(
Copy link
Collaborator

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?

Copy link
Contributor Author

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the annotation?

Copy link
Contributor Author

@andrevmatos andrevmatos Feb 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same from above comment

raiden/network/transport/matrix/__init__.py Outdated Show resolved Hide resolved
raiden/network/transport/matrix/__init__.py Outdated Show resolved Hide resolved
raiden/network/transport/matrix/utils.py Outdated Show resolved Hide resolved
raiden/network/transport/matrix/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ulope ulope left a 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]]
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ulope Implemented in #3427 , as well as splitting and tests for the server selection mechanism.

@ulope ulope merged commit 038a8fb into raiden-network:master Feb 6, 2019
@ulope ulope deleted the matrix_rooms branch February 6, 2019 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component / Transport Transport related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract server discovery and shared room discovery / creation into utility function
4 participants