summaryrefslogtreecommitdiff
path: root/tests/integration/test_udp.py
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-11-28 16:58:10 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-11-28 16:58:10 +0100
commit2a1b6673ffc96912322974cc85b93d13b6cd8e7c (patch)
treef545926f635f83ba148d8eb1b3e15bfdb9b4d115 /tests/integration/test_udp.py
parent595bfd57dc8179f9588e2a8d1e0efd1194e6246c (diff)
Simplify UDP scraper and prevent an incomplete 75th hash from being processed, adhering to the BEP now
Diffstat (limited to 'tests/integration/test_udp.py')
-rw-r--r--tests/integration/test_udp.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/integration/test_udp.py b/tests/integration/test_udp.py
index 1cb2389..3afe4ef 100644
--- a/tests/integration/test_udp.py
+++ b/tests/integration/test_udp.py
@@ -148,6 +148,28 @@ class UdpScrape(TrackerTestCase):
148 finally: 148 finally:
149 sock.close() 149 sock.close()
150 150
151 def test_a_hash_cut_short_is_not_scraped(self):
152 """What follows the last whole hash is not a hash, and the bytes that
153 would complete it are not the client's."""
154 info_hash = self.hash_for("udpcut")
155 sock, connection_id = self.tracker.udp_connect()
156 try:
157 sock.sendto(
158 struct.pack(">QII", connection_id, 2, 3) + info_hash + b"\x00" * 7, ("127.0.0.1", self.tracker.port)
159 )
160 self.assertEqual(len(sock.recv(2048)), 8 + 12)
161 finally:
162 sock.close()
163
164 def test_a_scrape_answers_no_more_hashes_than_the_protocol_allows(self):
165 sock, connection_id = self.tracker.udp_connect()
166 try:
167 hashes = b"".join(self.hash_for("udpmany%d" % n) for n in range(80))
168 sock.sendto(struct.pack(">QII", connection_id, 2, 4) + hashes, ("127.0.0.1", self.tracker.port))
169 self.assertEqual(len(sock.recv(2048)), 8 + 12 * 74)
170 finally:
171 sock.close()
172
151 173
152class UdpWorkersConfiguredAfterTheListener(TrackerTestCase): 174class UdpWorkersConfiguredAfterTheListener(TrackerTestCase):
153 """The harness writes its listen lines first, so this directive lands 175 """The harness writes its listen lines first, so this directive lands