test(relay-server): cover a full relay's multiaddr and ENR endpoints - #690
Merged
Conversation
Closes #118. The relay-server suite only exercised `enr_server` with synthetic listen addresses, so nothing in this crate covered a relay whose swarm actually bound a TCP and a UDP listener. Start one through `bind_relay`/`serve` — the path `run_relay_p2p_node` takes — on loopback ephemeral ports, and assert `GET /` advertises both transports with the relay's peer ID and that `GET /enr` reports the ports libp2p bound rather than the configured port 0. Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
| let peer = relay.peer_id; | ||
| let tcp = format!("/ip4/127.0.0.1/tcp/{}/p2p/{peer}", relay.tcp_port); | ||
| let udp = format!("/ip4/127.0.0.1/udp/{}/quic-v1/p2p/{peer}", relay.udp_port); | ||
| assert!(body.contains(&tcp), "missing {tcp} in {body:?}"); |
| let tcp = format!("/ip4/127.0.0.1/tcp/{}/p2p/{peer}", relay.tcp_port); | ||
| let udp = format!("/ip4/127.0.0.1/udp/{}/quic-v1/p2p/{peer}", relay.udp_port); | ||
| assert!(body.contains(&tcp), "missing {tcp} in {body:?}"); | ||
| assert!(body.contains(&udp), "missing {udp} in {body:?}"); |
iamquang95
approved these changes
Sep 9, 2026
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.
Closes #118.
The relay-server suite only exercised
enr_serverwith synthetic listen addresses, so nothing in this crate covered a relay whose swarm actually bound a TCP and a UDP listener.Adds two integration tests that start a whole relay through
bind_relay/serve— the pathrun_relay_p2p_nodetakes — with one TCP and one UDP listen address on loopback ephemeral ports, then assertGET /advertises both transports with the relay's peer ID appended, andGET /enrreports the ports libp2p actually bound (not the configured port 0). Mirrors charon@v1.7.1cmd/relay/relay_internal_test.go'sTestServeAddrsmultiaddrs/enr subtests. Tests only; no production code changed.Co-Authored-By: Bohdan Ohorodnii 35969035+varex83@users.noreply.github.com