From 355c8ae57d582974f4f6a4ba42f635f2253b84a7 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 6 Nov 2026 14:24:04 +0100 Subject: Add a wall clock helper so that statedumps can be written and re-read --- tests/integration/test_fullscrape.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/integration/test_fullscrape.py') diff --git a/tests/integration/test_fullscrape.py b/tests/integration/test_fullscrape.py index 3150612..45b3ffb 100644 --- a/tests/integration/test_fullscrape.py +++ b/tests/integration/test_fullscrape.py @@ -8,6 +8,7 @@ so these also exercise the chunked transfer the ordinary replies never take. import gzip import struct +import time import unittest from harness import TrackerTestCase, bdecode @@ -78,15 +79,14 @@ class FullScrape(TrackerTestCase): escaped = line.rsplit(b":", 2)[0] self.assertIn(b"%", escaped, "these hashes are mostly unprintable bytes") - def test_the_state_dump_carries_an_age_rather_than_a_peer_count(self): - """What a restart reads back. The second column is how many minutes - ago the torrent was last touched, not a stamp and not a count of - anybody: the clock counts from boot, so an absolute time would mean - nothing to the process that reads it.""" + def test_the_state_dump_carries_a_stamp_rather_than_a_peer_count(self): + """What a restart reads back. The second column is the minute the + torrent was last touched and not a count of anybody, by the wall + clock, which is the only one two runs of the tracker agree on.""" entries = self.entries_from_lines(self.scrape_all("/stats?mode=statedump")) self.assertIn(self.seeding.hex().upper().encode(), entries) - age, completed = entries[self.seeding.hex().upper().encode()] - self.assertEqual(int(age), 0, "announced a moment ago") + stamp, completed = entries[self.seeding.hex().upper().encode()] + self.assertAlmostEqual(int(stamp), int(time.time()) // 60, delta=1, msg="announced a moment ago") self.assertEqual(int(completed), 0) # ------------------------------------------------------------ shape -- cgit v1.3