diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:19:15 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:19:15 +0200 |
| commit | d5ba9552e27bac71168178f73a4c977a4d36dc1c (patch) | |
| tree | 1f0e08edc1bbad0b419042bc35ba36c7a62897b5 /packages/meshbay-node/tests | |
| parent | c3d41d1b4f042d09a637b375ce930190b7ea0d8c (diff) | |
| download | meshbay-d5ba9552e27bac71168178f73a4c977a4d36dc1c.tar.gz | |
fix(node): the answer log names its host addresses
aiortc ends a host candidate line at `typ host`, so the match on
" typ host " found none and logged `host: none` for every answer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/tests')
| -rw-r--r-- | packages/meshbay-node/tests/test_answer_host_log.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/test_answer_host_log.py b/packages/meshbay-node/tests/test_answer_host_log.py new file mode 100644 index 00000000..cde4e54b --- /dev/null +++ b/packages/meshbay-node/tests/test_answer_host_log.py @@ -0,0 +1,30 @@ +""" +The node's log names the host addresses it put in its answer. + +It is the first thing read when a member reports "DataChannel closed", and it +read `host: none` for every answer: the match wanted `" typ host "` with a space +after it, and aiortc ends a host candidate line at `typ host`. The addresses +below are the test node's of 2026-10-16. +""" + +from meshbay_node.transport.webrtc_server import _host_addresses + +ANSWER = "\r\n".join([ + "v=0", + "m=application 9 UDP/DTLS/SCTP webrtc-datachannel", + "a=candidate:7d8e0b5c 1 udp 2130706431 192.168.1.22 40125 typ host", + "a=candidate:3f1a9e22 1 udp 2130706431 2a01:cb15:80e8:de00:d455:bcab:c324:4d72 40125 typ host", + "a=candidate:c0a8c8fe 1 udp 2130706431 192.168.200.254 40125 typ host", + "a=candidate:9b0f1d47 1 udp 1694498815 90.112.206.172 40125 typ srflx raddr 192.168.1.22 rport 40125", + "a=end-of-candidates", +]) + "\r\n" + + +def test_host_candidates_ending_the_line_are_counted(): + assert _host_addresses(ANSWER) == { + "192.168.1.22", "2a01:cb15:80e8:de00:d455:bcab:c324:4d72", "192.168.200.254"} + + +def test_other_candidates_and_lines_are_not(): + assert _host_addresses("a=candidate:1 1 udp 1 90.112.206.172 9 typ srflx\r\n" + "a=ice-ufrag:typ host\r\n") == set() |