From 10b39dad1cd92cbcbd213957431594b3059f3be0 Mon Sep 17 00:00:00 2001 From: guha-rahul <69rahul16@gmail.com> Date: Sun, 15 Jun 2025 19:51:55 +0530 Subject: [PATCH 1/2] replace complex logic with decapsulate --- tests/core/identity/identify/test_identify.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/core/identity/identify/test_identify.py b/tests/core/identity/identify/test_identify.py index 5c8bf8e3..e88c7ebe 100644 --- a/tests/core/identity/identify/test_identify.py +++ b/tests/core/identity/identify/test_identify.py @@ -56,16 +56,9 @@ async def test_identify_protocol(security_protocol): ) # Check observed address - # TODO: use decapsulateCode(protocols('p2p').code) - # when the Multiaddr class will implement it host_b_addr = host_b.get_addrs()[0] - cleaned_addr = Multiaddr.join( - *( - host_b_addr.split()[:-1] - if str(host_b_addr.split()[-1]).startswith("/p2p/") - else host_b_addr.split() - ) - ) + host_b_peer_id = host_b.get_id() + cleaned_addr = host_b_addr.decapsulate(Multiaddr(f"/p2p/{host_b_peer_id}")) logger.debug("observed_addr: %s", Multiaddr(identify_response.observed_addr)) logger.debug("host_b.get_addrs()[0]: %s", host_b.get_addrs()[0]) From 193e8f9cb85e2eaeb0d591894ed2dfb415c50786 Mon Sep 17 00:00:00 2001 From: guha-rahul <69rahul16@gmail.com> Date: Sun, 15 Jun 2025 19:58:52 +0530 Subject: [PATCH 2/2] add newsfragment --- newsfragments/684.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 newsfragments/684.misc.rst diff --git a/newsfragments/684.misc.rst b/newsfragments/684.misc.rst new file mode 100644 index 00000000..0f16fb8f --- /dev/null +++ b/newsfragments/684.misc.rst @@ -0,0 +1 @@ +Uses the `decapsulate` method of the `Multiaddr` class to clean up the observed address.