multiaddr 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {multiaddr-0.1.0 → multiaddr-0.1.1}/HISTORY.rst +13 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/PKG-INFO +2 -2
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/__init__.py +1 -1
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/multiaddr.py +92 -48
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr.egg-info/PKG-INFO +2 -2
- {multiaddr-0.1.0 → multiaddr-0.1.1}/pyproject.toml +3 -3
- {multiaddr-0.1.0 → multiaddr-0.1.1}/tests/test_multiaddr.py +80 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/tests/test_protocols.py +3 -1
- {multiaddr-0.1.0 → multiaddr-0.1.1}/AUTHORS +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/CONTRIBUTING.rst +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/LICENSE-APACHE2 +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/LICENSE-MIT +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/MANIFEST.in +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/README.rst +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/__init__.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/certhash.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/cid.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/domain.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/fspath.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/garlic32.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/garlic64.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/http_path.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/ip4.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/ip6.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/ipcidr.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/memory.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/onion.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/onion3.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/uint16be.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/codecs/utf8.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/exceptions.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/protocols.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/resolvers/__init__.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/resolvers/base.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/resolvers/dns.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/transforms.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr/utils.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr.egg-info/SOURCES.txt +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr.egg-info/dependency_links.txt +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr.egg-info/not-zip-safe +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr.egg-info/requires.txt +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/multiaddr.egg-info/top_level.txt +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/setup.cfg +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/tests/__init__.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/tests/test_resolvers.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/tests/test_thin_waist_addresses.py +0 -0
- {multiaddr-0.1.0 → multiaddr-0.1.1}/tests/test_transforms.py +0 -0
|
@@ -3,6 +3,19 @@ History
|
|
|
3
3
|
|
|
4
4
|
.. towncrier release notes start
|
|
5
5
|
|
|
6
|
+
py-multiaddr v0.1.1 (2025-12-07)
|
|
7
|
+
--------------------------------
|
|
8
|
+
|
|
9
|
+
Bugfixes
|
|
10
|
+
~~~~~~~~
|
|
11
|
+
|
|
12
|
+
- Fixed validation for tag-only protocols (protocols that do not accept values).
|
|
13
|
+
Tag-only protocols like ``http``, ``https``, ``tls``, ``noise``, ``webrtc``, etc.
|
|
14
|
+
now correctly reject invalid value assignments via both ``/tag/value`` and
|
|
15
|
+
``/tag=value`` syntax, raising clear error messages that do not include the
|
|
16
|
+
invalid value. (`#98 <https://github.com/multiformats/py-multiaddr/issues/98>`__)
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
py-multiaddr v0.1.0 (2025-10-27)
|
|
7
20
|
--------------------------------
|
|
8
21
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiaddr
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Python implementation of jbenet's multiaddr
|
|
5
5
|
Author-email: Steven Buss <steven.buss@gmail.com>
|
|
6
6
|
Maintainer: acul71
|
|
7
7
|
Maintainer-email: pacrob <pacrob@protonmail.com>, Manu Sheel Gupta <manu@seeta.in>
|
|
8
8
|
License: MIT License
|
|
9
9
|
Project-URL: Homepage, https://github.com/multiformats/py-multiaddr
|
|
10
|
-
Project-URL: Download, https://github.com/multiformats/py-multiaddr/tarball/0.1.
|
|
10
|
+
Project-URL: Download, https://github.com/multiformats/py-multiaddr/tarball/0.1.1
|
|
11
11
|
Keywords: multiaddr
|
|
12
12
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -344,56 +344,54 @@ class Multiaddr(collections.abc.Mapping[Any, Any]):
|
|
|
344
344
|
return
|
|
345
345
|
|
|
346
346
|
# Handle other protocols
|
|
347
|
-
|
|
348
|
-
|
|
347
|
+
# Convert to list to allow peeking ahead for validation
|
|
348
|
+
parts_list = addr.strip("/").split("/")
|
|
349
|
+
if not parts_list:
|
|
349
350
|
raise exceptions.StringParseError("empty multiaddr", addr)
|
|
350
351
|
|
|
351
352
|
self._bytes = b""
|
|
352
|
-
|
|
353
|
+
idx: int = 0
|
|
354
|
+
while idx < len(parts_list):
|
|
355
|
+
part = parts_list[idx]
|
|
353
356
|
if not part:
|
|
357
|
+
idx += 1
|
|
354
358
|
continue
|
|
355
359
|
|
|
356
360
|
# Special handling for unix paths
|
|
357
361
|
if part in ("unix",):
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
protocol_path_value = next(parts)
|
|
361
|
-
if not protocol_path_value:
|
|
362
|
-
raise exceptions.StringParseError("empty protocol path", addr)
|
|
363
|
-
|
|
364
|
-
# Join any remaining parts as part of the path
|
|
365
|
-
remaining_parts = []
|
|
366
|
-
while True:
|
|
367
|
-
try:
|
|
368
|
-
next_part = next(parts)
|
|
369
|
-
if not next_part:
|
|
370
|
-
continue
|
|
371
|
-
remaining_parts.append(next_part)
|
|
372
|
-
except StopIteration:
|
|
373
|
-
break
|
|
374
|
-
|
|
375
|
-
if remaining_parts:
|
|
376
|
-
protocol_path_value = protocol_path_value + "/" + "/".join(remaining_parts)
|
|
377
|
-
|
|
378
|
-
proto = protocol_with_name(part)
|
|
379
|
-
codec = codec_by_name(proto.codec)
|
|
380
|
-
if not codec:
|
|
381
|
-
raise exceptions.StringParseError(f"unknown codec: {proto.codec}", addr)
|
|
382
|
-
|
|
383
|
-
try:
|
|
384
|
-
self._bytes += varint.encode(proto.code)
|
|
385
|
-
buf = codec.to_bytes(proto, protocol_path_value)
|
|
386
|
-
# Add length prefix for variable-sized or zero-sized codecs
|
|
387
|
-
if codec.SIZE <= 0:
|
|
388
|
-
self._bytes += varint.encode(len(buf))
|
|
389
|
-
if buf: # Only append buffer if it's not empty
|
|
390
|
-
self._bytes += buf
|
|
391
|
-
except Exception as e:
|
|
392
|
-
raise exceptions.StringParseError(str(e), addr) from e
|
|
393
|
-
continue
|
|
394
|
-
except StopIteration:
|
|
362
|
+
# Get the next part as the path value
|
|
363
|
+
if idx + 1 >= len(parts_list):
|
|
395
364
|
raise exceptions.StringParseError("missing value for unix protocol", addr)
|
|
396
365
|
|
|
366
|
+
protocol_path_value = parts_list[idx + 1]
|
|
367
|
+
if not protocol_path_value:
|
|
368
|
+
raise exceptions.StringParseError("empty protocol path", addr)
|
|
369
|
+
|
|
370
|
+
# Join any remaining parts as part of the path (collect and consume the rest)
|
|
371
|
+
remaining_parts = [p for p in parts_list[idx + 2 :] if p]
|
|
372
|
+
# Consume all remaining parts so outer loop ends
|
|
373
|
+
idx = len(parts_list)
|
|
374
|
+
|
|
375
|
+
if remaining_parts:
|
|
376
|
+
protocol_path_value = protocol_path_value + "/" + "/".join(remaining_parts)
|
|
377
|
+
|
|
378
|
+
proto = protocol_with_name(part)
|
|
379
|
+
codec = codec_by_name(proto.codec)
|
|
380
|
+
if not codec:
|
|
381
|
+
raise exceptions.StringParseError(f"unknown codec: {proto.codec}", addr)
|
|
382
|
+
|
|
383
|
+
try:
|
|
384
|
+
self._bytes += varint.encode(proto.code)
|
|
385
|
+
buf = codec.to_bytes(proto, protocol_path_value)
|
|
386
|
+
# Add length prefix for variable-sized or zero-sized codecs
|
|
387
|
+
if codec.SIZE <= 0:
|
|
388
|
+
self._bytes += varint.encode(len(buf))
|
|
389
|
+
if buf: # Only append buffer if it's not empty
|
|
390
|
+
self._bytes += buf
|
|
391
|
+
except Exception as e:
|
|
392
|
+
raise exceptions.StringParseError(str(e), addr) from e
|
|
393
|
+
continue # Already advanced idx above
|
|
394
|
+
|
|
397
395
|
# Handle other protocols
|
|
398
396
|
# Split protocol name and value if present
|
|
399
397
|
protocol_value: str | None = None
|
|
@@ -407,15 +405,30 @@ class Multiaddr(collections.abc.Mapping[Any, Any]):
|
|
|
407
405
|
except Exception as exc:
|
|
408
406
|
raise exceptions.StringParseError(f"unknown protocol: {proto_name}", addr) from exc
|
|
409
407
|
|
|
408
|
+
# Fix 2: Validate that tag-only protocols don't accept values via = syntax
|
|
409
|
+
if proto.codec is None and protocol_value is not None:
|
|
410
|
+
# Construct address string without the invalid value
|
|
411
|
+
# to avoid including it in error message
|
|
412
|
+
addr_parts_before = parts_list[:idx]
|
|
413
|
+
if addr_parts_before or proto_name:
|
|
414
|
+
addr_up_to_protocol = "/" + "/".join([*addr_parts_before, proto_name])
|
|
415
|
+
else:
|
|
416
|
+
addr_up_to_protocol = "/"
|
|
417
|
+
raise exceptions.StringParseError(
|
|
418
|
+
f"Protocol '{proto.name}' does not take an argument",
|
|
419
|
+
addr_up_to_protocol,
|
|
420
|
+
proto.name,
|
|
421
|
+
)
|
|
422
|
+
|
|
410
423
|
# If the protocol expects a value, get it
|
|
411
424
|
if proto.codec is not None:
|
|
412
425
|
if protocol_value is None:
|
|
413
|
-
|
|
414
|
-
protocol_value = next(parts)
|
|
415
|
-
except StopIteration:
|
|
426
|
+
if idx + 1 >= len(parts_list):
|
|
416
427
|
raise exceptions.StringParseError(
|
|
417
428
|
f"missing value for protocol: {proto_name}", addr
|
|
418
429
|
)
|
|
430
|
+
protocol_value = parts_list[idx + 1]
|
|
431
|
+
idx += 1 # Consume the value part
|
|
419
432
|
# Validate value (optional: could add more checks here)
|
|
420
433
|
# If value looks like a protocol name, that's an error
|
|
421
434
|
if protocol_value is not None:
|
|
@@ -434,13 +447,42 @@ class Multiaddr(collections.abc.Mapping[Any, Any]):
|
|
|
434
447
|
if not codec:
|
|
435
448
|
raise exceptions.StringParseError(f"unknown codec: {proto.codec}", addr)
|
|
436
449
|
|
|
437
|
-
|
|
450
|
+
# Special case: protocols with codec=None are flag protocols
|
|
451
|
+
# (no value, no length prefix, no buffer)
|
|
452
|
+
if proto.codec is None:
|
|
453
|
+
# Encode the protocol code first
|
|
438
454
|
self._bytes += varint.encode(proto.code)
|
|
439
455
|
|
|
440
|
-
#
|
|
441
|
-
#
|
|
442
|
-
|
|
443
|
-
|
|
456
|
+
# Fix 1: Check if next part exists and is not a valid protocol name
|
|
457
|
+
# If it's not a valid protocol, it's an invalid value
|
|
458
|
+
# Look ahead to find the next non-empty part
|
|
459
|
+
next_idx = idx + 1
|
|
460
|
+
while next_idx < len(parts_list) and not parts_list[next_idx]:
|
|
461
|
+
next_idx += 1
|
|
462
|
+
|
|
463
|
+
if next_idx < len(parts_list):
|
|
464
|
+
next_part = parts_list[next_idx]
|
|
465
|
+
try:
|
|
466
|
+
protocol_with_name(next_part)
|
|
467
|
+
# It's a valid protocol name, so advance idx to that part
|
|
468
|
+
idx = next_idx
|
|
469
|
+
continue
|
|
470
|
+
except exceptions.ProtocolNotFoundError:
|
|
471
|
+
# Not a valid protocol name, so it's an invalid value
|
|
472
|
+
# Construct address string up to (but not including) the invalid value
|
|
473
|
+
# to avoid including it in the error message
|
|
474
|
+
addr_up_to_protocol = "/" + "/".join(parts_list[: idx + 1])
|
|
475
|
+
raise exceptions.StringParseError(
|
|
476
|
+
f"Protocol '{proto.name}' does not take an argument",
|
|
477
|
+
addr_up_to_protocol,
|
|
478
|
+
proto.name,
|
|
479
|
+
)
|
|
480
|
+
# No next part, continue normally
|
|
481
|
+
idx += 1
|
|
482
|
+
continue
|
|
483
|
+
|
|
484
|
+
try:
|
|
485
|
+
self._bytes += varint.encode(proto.code)
|
|
444
486
|
|
|
445
487
|
buf = codec.to_bytes(proto, protocol_value or "")
|
|
446
488
|
if codec.SIZE <= 0: # Add length prefix for variable-sized or zero-sized codecs
|
|
@@ -450,6 +492,8 @@ class Multiaddr(collections.abc.Mapping[Any, Any]):
|
|
|
450
492
|
except Exception as e:
|
|
451
493
|
raise exceptions.StringParseError(str(e), addr) from e
|
|
452
494
|
|
|
495
|
+
idx += 1 # Move to next part
|
|
496
|
+
|
|
453
497
|
def _from_bytes(self, addr: bytes) -> None:
|
|
454
498
|
"""Parse a binary multiaddr.
|
|
455
499
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiaddr
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Python implementation of jbenet's multiaddr
|
|
5
5
|
Author-email: Steven Buss <steven.buss@gmail.com>
|
|
6
6
|
Maintainer: acul71
|
|
7
7
|
Maintainer-email: pacrob <pacrob@protonmail.com>, Manu Sheel Gupta <manu@seeta.in>
|
|
8
8
|
License: MIT License
|
|
9
9
|
Project-URL: Homepage, https://github.com/multiformats/py-multiaddr
|
|
10
|
-
Project-URL: Download, https://github.com/multiformats/py-multiaddr/tarball/0.1.
|
|
10
|
+
Project-URL: Download, https://github.com/multiformats/py-multiaddr/tarball/0.1.1
|
|
11
11
|
Keywords: multiaddr
|
|
12
12
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "multiaddr"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.1"
|
|
8
8
|
description = "Python implementation of jbenet's multiaddr"
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
authors = [{ name = "Steven Buss", email = "steven.buss@gmail.com" }]
|
|
@@ -44,7 +44,7 @@ dependencies = [
|
|
|
44
44
|
|
|
45
45
|
[project.urls]
|
|
46
46
|
Homepage = "https://github.com/multiformats/py-multiaddr"
|
|
47
|
-
Download = "https://github.com/multiformats/py-multiaddr/tarball/0.1.
|
|
47
|
+
Download = "https://github.com/multiformats/py-multiaddr/tarball/0.1.1"
|
|
48
48
|
|
|
49
49
|
[project.optional-dependencies]
|
|
50
50
|
dev = [
|
|
@@ -137,7 +137,7 @@ name = "Removals"
|
|
|
137
137
|
showcontent = true
|
|
138
138
|
|
|
139
139
|
[tool.bumpversion]
|
|
140
|
-
current_version = "0.1.
|
|
140
|
+
current_version = "0.1.1"
|
|
141
141
|
parse = """
|
|
142
142
|
(?P<major>\\d+)
|
|
143
143
|
\\.(?P<minor>\\d+)
|
|
@@ -1022,3 +1022,83 @@ def test_http_path_raw_value_access():
|
|
|
1022
1022
|
from urllib.parse import quote
|
|
1023
1023
|
|
|
1024
1024
|
assert quote(raw_value, safe="") == encoded_value
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
def test_tag_only_protocol_rejects_value_slash_syntax():
|
|
1028
|
+
"""Test that tag-only protocols reject values using /tag/value syntax"""
|
|
1029
|
+
tag_only_protocols = [
|
|
1030
|
+
"webrtc",
|
|
1031
|
+
"webrtc-direct",
|
|
1032
|
+
"noise",
|
|
1033
|
+
"quic",
|
|
1034
|
+
"quic-v1",
|
|
1035
|
+
"tls",
|
|
1036
|
+
"http",
|
|
1037
|
+
"https",
|
|
1038
|
+
"ws",
|
|
1039
|
+
"wss",
|
|
1040
|
+
"p2p-circuit",
|
|
1041
|
+
"webtransport",
|
|
1042
|
+
]
|
|
1043
|
+
|
|
1044
|
+
for proto_name in tag_only_protocols:
|
|
1045
|
+
# Should fail with clear error message
|
|
1046
|
+
with pytest.raises(StringParseError) as exc_info:
|
|
1047
|
+
Multiaddr(f"/{proto_name}/value")
|
|
1048
|
+
assert "does not take an argument" in str(exc_info.value)
|
|
1049
|
+
assert proto_name in str(exc_info.value)
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
def test_tag_only_protocol_rejects_value_equals_syntax():
|
|
1053
|
+
"""Test that tag-only protocols reject values using /tag=value syntax"""
|
|
1054
|
+
tag_only_protocols = [
|
|
1055
|
+
"webrtc",
|
|
1056
|
+
"webrtc-direct",
|
|
1057
|
+
"noise",
|
|
1058
|
+
"quic",
|
|
1059
|
+
"tls",
|
|
1060
|
+
"http",
|
|
1061
|
+
]
|
|
1062
|
+
|
|
1063
|
+
for proto_name in tag_only_protocols:
|
|
1064
|
+
# Should fail with clear error message
|
|
1065
|
+
with pytest.raises(StringParseError) as exc_info:
|
|
1066
|
+
Multiaddr(f"/{proto_name}=value")
|
|
1067
|
+
assert "does not take an argument" in str(exc_info.value)
|
|
1068
|
+
assert proto_name in str(exc_info.value)
|
|
1069
|
+
|
|
1070
|
+
|
|
1071
|
+
def test_tag_only_protocol_allows_valid_combinations():
|
|
1072
|
+
"""Test that tag-only protocols work correctly in valid combinations"""
|
|
1073
|
+
# Single tag protocol
|
|
1074
|
+
assert str(Multiaddr("/webrtc")) == "/webrtc"
|
|
1075
|
+
assert str(Multiaddr("/webrtc-direct")) == "/webrtc-direct"
|
|
1076
|
+
|
|
1077
|
+
# Multiple tag protocols chained
|
|
1078
|
+
assert str(Multiaddr("/webrtc/noise")) == "/webrtc/noise"
|
|
1079
|
+
assert str(Multiaddr("/webrtc-direct/webrtc")) == "/webrtc-direct/webrtc"
|
|
1080
|
+
|
|
1081
|
+
# Tag protocol followed by value protocol
|
|
1082
|
+
assert str(Multiaddr("/webrtc-direct/ip4/127.0.0.1")) == "/webrtc-direct/ip4/127.0.0.1"
|
|
1083
|
+
|
|
1084
|
+
# Complex valid address
|
|
1085
|
+
addr = "/ip4/127.0.0.1/udp/9090/webrtc-direct/certhash/uEiDDq4_xNyDorZBH3TlGazyJdOWSwvo4PUo5YHFMrvDE8g"
|
|
1086
|
+
assert str(Multiaddr(addr)) == addr
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
def test_tag_only_protocol_error_message_format():
|
|
1090
|
+
"""Test that error messages for tag-only protocols are clear and helpful"""
|
|
1091
|
+
# Test /tag/value syntax
|
|
1092
|
+
with pytest.raises(StringParseError) as exc_info:
|
|
1093
|
+
Multiaddr("/webrtc-direct/invalidvalue")
|
|
1094
|
+
error_msg = str(exc_info.value)
|
|
1095
|
+
assert "does not take an argument" in error_msg
|
|
1096
|
+
assert "webrtc-direct" in error_msg
|
|
1097
|
+
assert "invalidvalue" not in error_msg # Should not mention the invalid value
|
|
1098
|
+
|
|
1099
|
+
# Test /tag=value syntax
|
|
1100
|
+
with pytest.raises(StringParseError) as exc_info:
|
|
1101
|
+
Multiaddr("/webrtc=somevalue")
|
|
1102
|
+
error_msg = str(exc_info.value)
|
|
1103
|
+
assert "does not take an argument" in error_msg
|
|
1104
|
+
assert "webrtc" in error_msg
|
|
@@ -565,7 +565,9 @@ def test_ipcidr_invalid_bytes_inputs():
|
|
|
565
565
|
|
|
566
566
|
# --------CERT-HASH---------
|
|
567
567
|
|
|
568
|
-
|
|
568
|
+
# The multihash package provides `encode` at runtime, but some static
|
|
569
|
+
# checkers (ruff/pyright) may not see it. Ignore the attribute check here.
|
|
570
|
+
VALID_MULTIHASH_BYTES = multihash.encode(b"hello world", "sha2-256") # type: ignore[attr-defined]
|
|
569
571
|
VALID_CERTHASH_STRING = multibase.encode("base64url", VALID_MULTIHASH_BYTES).decode("utf-8")
|
|
570
572
|
|
|
571
573
|
INVALID_BYTES = b"this is not a multihash"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|