diff options
Diffstat (limited to 'tests/integration')
| -rw-r--r-- | tests/integration/test_udp.py | 22 |
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 | ||
| 152 | class UdpWorkersConfiguredAfterTheListener(TrackerTestCase): | 174 | class 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 |
