Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566package spindle
import ( "log/slog" "testing"
"github.com/bluesky-social/indigo/atproto/syntax"
"tangled.org/core/api/org_tangled" "tangled.org/core/tapc")
func TestBackfilledRecordsOfAServedRepoLeaveItsMarkToTheCatchUp(t *testing.T) { env := newEnsureEnv(t) env.serve("repo", testBob) env.ensure(t) b := newBackfill(env.s, slog.Default(), shortTempDir(t)) before := env.knot.count()
manifest := markEvent(testRepoDid, env.spindleDid(), testOwner) collaborator := recordEvent(testRepoDid, org_tangled.GraphCollaboratorNSID, testBob.String(), tapc.RecordCreateAction, map[string]string{}) handleBackfilled(t, b, manifest, collaborator) requireMarked(t, env.s.db, testRepoDid, false, "a served repo's backfilled records marked it") if got := env.knot.count(); got != before { t.Fatalf("backfilled records cost %d knot requests", got-before) }
handleBackfilled(t, b, declarationEvent(testOwner, testRepoDid, tapc.RecordCreateAction)) requireMarked(t, env.s.db, testRepoDid, false, "a served repo's backfilled declaration marked it")}
func TestABackfilledDeclarationOfARepoNotServedYetStillMarksIt(t *testing.T) { env := newEnsureEnv(t) b := newBackfill(env.s, slog.Default(), shortTempDir(t))
handleBackfilled(t, b, declarationEvent(testOwner, testRepoDid, tapc.RecordCreateAction)) requireMarked(t, env.s.db, testRepoDid, true, "a new repo's backfilled declaration left no mark")}
func TestABackfilledDeclarationThatNamesAnotherRepoStillMarksIt(t *testing.T) { env := newEnsureEnv(t) env.serve("repo", testBob) env.ensure(t) b := newBackfill(env.s, slog.Default(), shortTempDir(t))
other := syntax.DID("did:plc:otherrepo") handleBackfilled(t, b, declarationEvent(testOwner, other, tapc.RecordCreateAction)) requireMarked(t, env.s.db, other, true, "a backfilled declaration naming another repo left no mark")}
func TestAServedRepoWhoseBackfillFailedIsMarkedAnyway(t *testing.T) { f := &fakeHydrant{} failOn(f, pendingRepo) b := catchUpBackfill(t, f) if err := b.CatchUp(); err != nil { t.Fatal(err) }
runRound(t, b)
requireMarked(t, b.s.db, pendingRepo, true, "the served repo wasn't marked after its backfill failed") if got := pendingDids(t, b); len(got) == 0 { t.Fatal("the failed repo left the pending list, it has to stay for the next round") }}