From: Štěpán Balážik Date: Tue, 14 May 2024 14:26:44 +0000 (+0200) Subject: Add a helper for uncompressed length of dnspython's dns.name.Name X-Git-Tag: v9.20.0~21^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9584a7bdcd5978165a14348247fa670025172257;p=thirdparty%2Fbind9.git Add a helper for uncompressed length of dnspython's dns.name.Name This is useful for generating using hypothesis but also for other cases. --- diff --git a/bin/tests/system/isctest/hypothesis/strategies.py b/bin/tests/system/isctest/hypothesis/strategies.py index 1e05cc1932b..d26a90b1c2d 100644 --- a/bin/tests/system/isctest/hypothesis/strategies.py +++ b/bin/tests/system/isctest/hypothesis/strategies.py @@ -29,6 +29,8 @@ import dns.message import dns.rdataclass import dns.rdatatype +import isctest.name + @composite def dns_names( @@ -73,7 +75,7 @@ def dns_names( try: outer_name = prefix + suffix - remaining_bytes = 255 - len(outer_name.to_wire()) + remaining_bytes = 255 - isctest.name.len_wire_uncompressed(outer_name) assert remaining_bytes >= 0 except dns.name.NameTooLong: warn( diff --git a/bin/tests/system/isctest/name.py b/bin/tests/system/isctest/name.py index f5b6de52c34..d992ae3fce9 100644 --- a/bin/tests/system/isctest/name.py +++ b/bin/tests/system/isctest/name.py @@ -14,3 +14,7 @@ import dns.name def prepend_label(label: str, name: dns.name.Name) -> dns.name.Name: return dns.name.Name((label,) + name.labels) + + +def len_wire_uncompressed(name: dns.name.Name) -> int: + return len(name) + sum(map(len, name.labels))