From d501bbc97aeb87e6e4aa50bb2fa10a157d5909e9 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 3 Nov 2026 05:13:22 +0100 Subject: Let a tracker with live sync built in run without a cluster --- tests/integration/test_livesync.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests') diff --git a/tests/integration/test_livesync.py b/tests/integration/test_livesync.py index 1659a41..3a9ee58 100644 --- a/tests/integration/test_livesync.py +++ b/tests/integration/test_livesync.py @@ -130,3 +130,37 @@ class LiveSyncAccess(TrackerTestCase): info_hash = self.hash_for("sync-unblessed") self.tracker.livesync_send(packet(SYNC_PEER4, [(info_hash, peer4("10.1.2.12", 6881, FLAG_SEEDING))])) self.assertFalse(self.tracker.wait_until(lambda: self.tracker.torrent_count() != 0, timeout=1)) + + +@unittest.skipUnless(has_livesync(), "this build has no WANT_SYNC_LIVE") +class LiveSyncUnconfigured(TrackerTestCase): + """A binary that has the feature but no cluster to join. Somebody whose + packager turned WANT_SYNC_LIVE on did not ask for live sync and should + not be able to tell that it is there.""" + + config = "" + + def test_the_tracker_runs_anyway(self): + info_hash = self.hash_for("no-cluster") + self.tracker.announce(info_hash, port=6881, left=0) + self.assertEqual(self.tracker.torrent_count(), 1) + + def test_nothing_is_said_about_the_missing_cluster(self): + self.assertNotIn("sync", self.tracker.output().lower()) + + def test_no_socket_is_bound_for_it(self): + """A configured tracker holds the wildcard address on that port, so + taking it here proves nothing was started.""" + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + try: + sock.bind(("0.0.0.0", self.tracker.livesync_port)) + finally: + sock.close() + + def test_announcing_stays_clean(self): + """Enough announces to pass the watermark that would flush an + outgoing buffer, if there were one to flush. The sanitizers in this + build turn anything the attempt touched into a failure.""" + for i in range(200): + self.tracker.announce(self.hash_for("no-cluster-%d" % i), port=6881 + i, left=0) + self.assertEqual(self.tracker.torrent_count(), 200) -- cgit v1.3