Artifact 2f35d3f205ed8a08d9160023eba2ee7824e086e4bc83b5f942a6e72346928d25:
- File
internal/sync/sparse_prepared_shun_test.go
— part of check-in
[632e7349e6]
at
2026-10-21 01:03:54
on branch feat/submanifest-reader
— fix(sync): isolate prepared fallback cache and cancellation
Never share RID-keyed cache state across prepared service transactions: protocol-fatal responses can roll back after expansion while returning a nil Go error. Reject canceled contexts before acquiring a transaction and propagate observer cancellation instead of serving densely.
Reproduce rollback, RID reuse and incorrect content under the replacement hash; verify cancellation and deadline responses do no dense work. Exercise newly shunned payload and basis suppression after prepared-proof invalidation. (user: [email protected], size: 1333) [annotate] [blame] [check-ins using] [more...]
package sync import ( "context" "fmt" "testing" "github.com/danmestas/go-libfossil/internal/xfer" ) // Invalidate the proof after preparation, then verify the actual dense fallback // emits neither the newly shunned payload nor a dependency on that basis. func TestPreparedSparseServiceShunFallback(t *testing.T) { for _, private := range []bool{false, true} { for _, requested := range []bool{false, true} { t.Run(fmt.Sprintf("private=%v/gimme=%v", private, requested), func(t *testing.T) { r, baseUUID, targetUUID := shunSendFixture(t, private) service, err := prepareSparseService(context.Background(), r, HandleOpts{}) if err != nil { t.Fatal(err) } defer service.Close() if _, err := r.DB().Exec("INSERT INTO shun(uuid,mtime) VALUES(?,0)", baseUUID); err != nil { t.Fatal(err) } cards := []xfer.Card{&xfer.PragmaCard{Name: "cone", Values: []string{"src"}}} cards = append(cards, shunSendCards(private, requested, baseUUID, targetUUID)...) transport := &preparedSparseTransport{service: service} resp, err := transport.Exchange(context.Background(), &xfer.Message{Cards: cards}) if err != nil { t.Fatal(err) } if transport.applied != 0 { t.Fatal("stale proof applied") } assertShunSend(t, resp, baseUUID, targetUUID) }) } } }