The town: a fake community across the pasture, checked for coherence
tools/pasture/town/ (run through tools/pasture/town.sh) seeds a fake community across every running peer and checks that all of them, and PrivaPub, agree on what happened: - drivers per platform on four dialect bases (Mastodon API, Misskey API, Lemmy API, PrivaPub with /clientapi), each with a selftest against its own server; what a server holds is read from its database, never by making it fetch; - a deterministic generator (specs/village.json: 23 accounts on seven servers, roots with several personas, circles and communities, a cross-server follow graph, posts of every kind and visibility, reply rounds, likes, boosts, reactions, votes, edits, deletes, blocks, mutes and a report) and a seeder that keeps a ledger of what happened; - a sweep that expects delivery and confinement per server, what each account sees, counts, threads, edits, deletes, follows and privacy rows (sibling keys, published days, canary root credentials in every peer's database, located posts that never leave), with what the peers do on purpose modelled (Misskey drops orphan replies, Lemmy keeps only community content, edits go to the post's own audience); - known gaps (gaps.json) turn failures into xfail and passes into xpass; a self-contained report.html, and docs/INTEROP-BACKLOG.md. The pasture moves to a public-looking subnet (peers with no private address switch can join), takes PASTURE_PORT when 6971 is in use, adds peers to a running pasture (run.sh add, Caddy recreated with its CA kept), removes its volumes on down, writes every scenario check to out/scenarios.jsonl, serves decePub as decepub.test for its e2e tests, lifts GoToSocial's and Lemmy's own rate limits, trusts Caddy in Mastodon (TRUSTED_PROXY_IP) and gains Hollo (Fedify), whose one login owning several accounts is the nearest peer to PrivaPub's personas. The first village found the four PrivaPub bugs fixed in the commits before this one; the second run, on the fixed server, passes 2319 checks with 11 failures left, all between peers or from Lemmy's send worker, which the seeder now warms up first. ROADMAP records the owner's decisions of 2026-10-04 (the town, and P9 back from the cut list). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
d6131af289
commit
2873344690
46 files changed
+4400
-24
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,79 @@
|
||||
"""The town's own logic, with no pasture: python3 -m unittest discover -s tools/pasture/town/tests"""
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import check # noqa: E402
|
||||
import gen # noqa: E402
|
||||
from core.rng import Rng # noqa: E402
|
||||
|
||||
|
||||
class RngTests(unittest.TestCase):
|
||||
def test_the_same_seed_and_name_give_the_same_stream(self):
|
||||
a, b = Rng(7, "x"), Rng(7, "x")
|
||||
self.assertEqual([a.next64() for _ in range(5)], [b.next64() for _ in range(5)])
|
||||
|
||||
def test_substreams_do_not_disturb_each_other(self):
|
||||
root = Rng(7)
|
||||
before = Rng(7).sub("graph").next64()
|
||||
root.sub("content").next64()
|
||||
self.assertEqual(before, root.sub("graph").next64())
|
||||
|
||||
def test_below_stays_in_range(self):
|
||||
r = Rng(1)
|
||||
self.assertTrue(all(0 <= r.below(3) < 3 for _ in range(1000)))
|
||||
|
||||
|
||||
class PlanTests(unittest.TestCase):
|
||||
def test_a_spec_always_plans_the_same(self):
|
||||
spec = gen.load("village")
|
||||
self.assertEqual(gen.digest(gen.plan(spec)), gen.digest(gen.plan(spec)))
|
||||
|
||||
def test_every_post_names_its_marker_and_every_reply_a_parent_planned_before_it(self):
|
||||
planner = gen.Planner(gen.load("village"))
|
||||
steps = planner.plan()
|
||||
made = set()
|
||||
for s in steps:
|
||||
if s["verb"] != "post":
|
||||
continue
|
||||
self.assertIn(f"({s['ref']})", s["args"]["text"])
|
||||
if s["args"].get("reply_to"):
|
||||
self.assertIn(s["args"]["reply_to"], made)
|
||||
made.add(s["ref"])
|
||||
|
||||
def test_lemmy_accounts_never_follow_people_and_platforms_get_only_what_they_can_do(self):
|
||||
steps = gen.plan(gen.load("village"))
|
||||
for s in steps:
|
||||
platform = s["actor"].split("/")[0]
|
||||
if s["verb"] == "follow":
|
||||
self.assertNotEqual("lemmy", platform)
|
||||
if s["verb"] in ("react", "edit", "vote", "boost"):
|
||||
self.assertIn({"react": "react", "edit": "edit", "vote": "vote", "boost": "boost"}[s["verb"]], gen.CAPS[platform])
|
||||
|
||||
def test_a_stored_plan_rebuilds_the_same_world(self):
|
||||
planner = gen.Planner(gen.load("village"))
|
||||
planner.plan()
|
||||
stored = gen.Stored(gen.snapshot(planner))
|
||||
self.assertEqual(planner.objects.keys(), stored.objects.keys())
|
||||
self.assertEqual(planner.objects["p1"]["mentions"], stored.objects["p1"]["mentions"])
|
||||
|
||||
|
||||
class GapTests(unittest.TestCase):
|
||||
def test_a_known_gap_turns_failures_into_xfail_and_passes_into_xpass(self):
|
||||
gaps = [{"id": "G-9", "match": {"feature": r"count\.like\..*", "observer": "privapub"}, "status": "open"}]
|
||||
checks = check.classify([
|
||||
{"feature": "count.like.followers", "observer": "privapub", "ok": False},
|
||||
{"feature": "count.like.public", "observer": "privapub", "ok": True},
|
||||
{"feature": "count.like.public", "observer": "gts", "ok": False},
|
||||
], gaps)
|
||||
self.assertEqual(["xfail", "xpass", "fail"], [c["status"] for c in checks])
|
||||
|
||||
def test_a_closed_gap_matches_nothing(self):
|
||||
gaps = [{"id": "G-9", "match": {"feature": ".*"}, "status": "closed"}]
|
||||
self.assertEqual("fail", check.classify([{"feature": "x", "ok": False}], gaps)[0]["status"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user