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

chore: add peer connecting event #693

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

glevco
Copy link
Contributor

@glevco glevco commented Jul 11, 2023

Motivation

This PR is in preparation for PubSub changes in #694. The current implementation of the test_p2p_network_events() test,

# This will trigger sending to the pubsub one of the network events
manager.connections.connect_to(endpoint, use_ssl=True)

Tries to start a connection, which fails because the reactor used in tests (Clock) doesn't support TCP connections. This fail is expected and triggers the emission of the PubSub NETWORK_PEER_CONNECTION_FAILURE event, which is what triggers the Metrics update, making the test work.

In #694, the Clock is getting changed to a MemoryReactorClock, which does support TCP connections (but doesn't complete them), so the NETWORK_PEER_CONNECTION_FAILURE is not triggered.

We add an almost effectless new NETWORK_PEER_CONNECTING event that gets triggered when the peers starts connecting, so the Metrics update is still triggered.

Acceptance Criteria

  • Create new HathorEvents.NETWORK_PEER_CONNECTING event
    • Emit the event when a peer starts connecting to the p2p manager
    • Subscribe to the event and handle it in Metrics

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged

@glevco glevco self-assigned this Jul 11, 2023
@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #693 (02a3548) into master (0dd129d) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 02a3548 differs from pull request most recent head 67e0848. Consider uploading reports for the commit 67e0848 to get more accurate results

@@            Coverage Diff             @@
##           master     #693      +/-   ##
==========================================
+ Coverage   84.10%   84.12%   +0.01%     
==========================================
  Files         246      246              
  Lines       20446    20448       +2     
  Branches     2759     2759              
==========================================
+ Hits        17197    17201       +4     
+ Misses       2674     2673       -1     
+ Partials      575      574       -1     
Impacted Files Coverage Δ
hathor/metrics.py 86.30% <ø> (ø)
hathor/p2p/manager.py 72.58% <100.00%> (+0.06%) ⬆️
hathor/pubsub.py 96.00% <100.00%> (+0.05%) ⬆️

... and 1 file with indirect coverage changes

@glevco glevco force-pushed the chore/peer-connecting-event branch from d1f4193 to 02a3548 Compare July 11, 2023 21:06
@glevco glevco force-pushed the chore/peer-connecting-event branch from 02a3548 to 67e0848 Compare July 11, 2023 21:49
@glevco glevco marked this pull request as ready for review July 11, 2023 21:52
@glevco glevco requested review from jansegre and msbrogli as code owners July 11, 2023 21:52
@msbrogli msbrogli merged commit 67e0848 into master Jul 11, 2023
@msbrogli msbrogli deleted the chore/peer-connecting-event branch July 11, 2023 22:08
@jansegre jansegre mentioned this pull request Jul 12, 2023
2 tasks
This was referenced Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants