Repository navigation
Enrich HTTP core Event::TcpAnnounce event - #1472
Merged
josecelano merged 8 commits intoApr 22, 2025
Merged
josecelano merged 8 commits into
josecelano merged 8 commits into
Conversation
josecelano
marked this pull request as draft
April 22, 2025 11:01
josecelano
force-pushed
the
1376-add-announced-peer-to-http-core-announce-event
branch
from
April 22, 2025 11:02
f4116a2 to
a67e137
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1472 +/- ##
===========================================
+ Coverage 84.49% 84.51% +0.02%
===========================================
Files 254 255 +1
Lines 19337 19437 +100
Branches 19337 19437 +100
===========================================
+ Hits 16338 16427 +89
- Misses 2716 2726 +10
- Partials 283 284 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This test has been added becuase this code was not working:
```rust
let mut announced_peer = peer_copy;
announced_peer.peer_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
let mut added_peer = peer;
added_peer.peer_addr = SocketAddr::new(
IpAddr::V6(Ipv6Addr::new(0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969, 0x6969)),
8080,
);
let mut http_stats_event_sender_mock = MockHttpStatsEventSender::new();
http_stats_event_sender_mock
.expect_send_event()
.with(eq(Event::TcpAnnounce {
connection: ConnectionContext::new(
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
Some(8080),
server_service_binding,
),
announced_peer: peer,
added_peer: peer,
}))
.times(1)
.returning(|_| Box::pin(future::ready(Some(Ok(1)))));
```
using the same events:
Event sent:
TcpAnnounce { connection: ConnectionContext { client: ClientConnectionContext { ip_addr: 127.0.0.1, port: Some(8080) }, server: ServerConnectionContext { service_binding: ServiceBinding { protocol: HTTP, bind_address: 127.0.0.1:7070 } } }, announced_peer: Peer { peer_id: PeerId([45, 113, 66, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), peer_addr: 127.0.0.1:8080, updated: 1745316858.487824645s, uploaded: NumberOfBytes(I64(0)), downloaded: NumberOfBytes(I64(0)), left: NumberOfBytes(I64(0)), event: Started }, added_peer: Peer { peer_id: PeerId([45, 113, 66, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), peer_addr: [6969:6969:6969:6969:6969:6969:6969:6969]:8080, updated: 1745316858.487824645s, uploaded: NumberOfBytes(I64(0)), downloaded: NumberOfBytes(I64(0)), left: NumberOfBytes(I64(0)), event: Started } }
Event expected in the mock:
TcpAnnounce { connection: ConnectionContext { client: ClientConnectionContext { ip_addr: 127.0.0.1, port: Some(8080) }, server: ServerConnectionContext { service_binding: ServiceBinding { protocol: HTTP, bind_address: 127.0.0.1:7070 } } }, announced_peer: Peer { peer_id: PeerId([45, 113, 66, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), peer_addr: 127.0.0.1:8080, updated: 1745316858.487824645s, uploaded: NumberOfBytes(I64(0)), downloaded: NumberOfBytes(I64(0)), left: NumberOfBytes(I64(0)), event: Started }, added_peer: Peer { peer_id: PeerId([45, 113, 66, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]), peer_addr: [6969:6969:6969:6969:6969:6969:6969:6969]:8080, updated: 1745316858.487824645s, uploaded: NumberOfBytes(I64(0)), downloaded: NumberOfBytes(I64(0)), left: NumberOfBytes(I64(0)), event: Started } }
That's one of the reasons why the expectation was changed. The other
reason is the only relevant part for the peer in the test is the updated peer
address.
josecelano
marked this pull request as ready for review
April 22, 2025 11:32
Peer and added Peer to HTTP core TcpAnnounce eventPeer to HTTP core TcpAnnounce event
josecelano
marked this pull request as draft
April 22, 2025 15:06
…he peer IP may change before adding the peer to the swarm, and the original remote client ip is already included in the `ConnectionCotext`.
…vent::TcpAnnounce
Member
Author
|
ACK a422e4e |
josecelano
marked this pull request as ready for review
April 22, 2025 16:21
Peer to HTTP core TcpAnnounce eventEvent::TcpAnnounce event
Contributor
|
Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: Only 112 of the 282 executable lines it added remain on the default branch, at their own paths or in the files those paths were later renamed to; the rest has since been rewritten or removed. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
info_hashandannouncement(peer announce request data):