Skip to content

Commit 0caf864

Browse files
authored
Merge pull request #684 from guha-rahul/use_decapsulate
fix: replace complex logic with decapsulate
2 parents d2825af + 193e8f9 commit 0caf864

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

newsfragments/684.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Uses the `decapsulate` method of the `Multiaddr` class to clean up the observed address.

tests/core/identity/identify/test_identify.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,9 @@ async def test_identify_protocol(security_protocol):
5656
)
5757

5858
# Check observed address
59-
# TODO: use decapsulateCode(protocols('p2p').code)
60-
# when the Multiaddr class will implement it
6159
host_b_addr = host_b.get_addrs()[0]
62-
cleaned_addr = Multiaddr.join(
63-
*(
64-
host_b_addr.split()[:-1]
65-
if str(host_b_addr.split()[-1]).startswith("/p2p/")
66-
else host_b_addr.split()
67-
)
68-
)
60+
host_b_peer_id = host_b.get_id()
61+
cleaned_addr = host_b_addr.decapsulate(Multiaddr(f"/p2p/{host_b_peer_id}"))
6962

7063
logger.debug("observed_addr: %s", Multiaddr(identify_response.observed_addr))
7164
logger.debug("host_b.get_addrs()[0]: %s", host_b.get_addrs()[0])

0 commit comments

Comments
 (0)