48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
"""B-69: in-code comments that describe the rest of the system must stay true.
|
|||
|
|
|
||
|
|
Three had rotted: the reconciler still called the payout retry "a future
|
||
|
|
payout-retry routine — still an open gap" long after B-26 shipped it,
|
||
|
|
app/db/base.py sized the SQLite busy timeout against "five" background tasks
|
||
|
|
when there are six, and app/auth/routes.py cited the wrong B-nn. A comment is
|
||
|
|
invisible to every other test in the suite, so the claims are pinned here.
|
||
|
|
"""
|
||
|
|
|
||
|
|
import re
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
_ROOT = Path(__file__).resolve().parents[2]
|
||
|
|
|
||
|
|
|
||
|
|
def _read(relative: str) -> str:
|
||
|
|
return (_ROOT / relative).read_text(encoding="utf-8")
|
||
|
|
|
||
|
|
|
||
|
|
def test_background_task_count_in_the_busy_timeout_comment_is_right():
|
||
|
|
started = len(re.findall(r"asyncio\.create_task\(", _read("app/main.py")))
|
||
|
|
assert started == 6, "the lifespan's task count changed — update app/db/base.py's comment"
|
||
|
|
|
||
|
|
comment = _read("app/db/base.py").split("_SQLITE_BUSY_TIMEOUT_MS", 1)[0]
|
||
|
|
match = re.search(r"(\w+) concurrent background tasks", comment)
|
||
|
|
assert match, "app/db/base.py no longer explains what the busy timeout is sized for"
|
||
|
|
words = {"four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8}
|
||
|
|
assert words.get(match.group(1)) == started
|
||
|
|
|
||
|
|
|
||
|
|
def test_the_reconciler_does_not_call_the_payout_retry_an_open_gap():
|
||
|
|
source = _read("app/tx/reconcile.py")
|
||
|
|
assert "still an open gap" not in source
|
||
|
|
# It exists (B-26) and is what actually recovers an abandoned payout, so the
|
||
|
|
# comment must point at it rather than at an operator.
|
||
|
|
assert "B-26" in source
|
||
|
|
|
||
|
|
|
||
|
|
def test_the_payout_retry_the_comment_points_at_still_exists():
|
||
|
|
assert "_retry_payout_if_due" in _read("app/rounds/scheduler.py")
|
||
|
|
|
||
|
|
|
||
|
|
def test_the_login_throttle_comment_cites_its_own_finding():
|
||
|
|
limiters = _read("app/auth/routes.py").split("_rate_limiters", 1)[1][:1500]
|
||
|
|
assert "B-33" in limiters
|
||
|
|
assert "B-31" not in limiters # B-31 is the resubscribe fan-out, a different fix
|