Artifact 48926521669ec4033bc2186bd336ef3f13a2bd9cd6bdccbd54a8bb7a89e6b2f7:
- File
conformance/horizon_history_zit_test.go
— part of check-in
[fe06d02a12]
at
2026-10-23 02:20:22
on branch feat/horizon-cones
— feat(sync): name a history URL in horizon-served
draft-fossil-horizon-00 §6.2.5 lets an origin append to pragma horizon-served the URL of an interface outside the protocol at which history below a horizon can be queried, and §5.5 has a client direct the user there. go-libfossil emitted the level alone and dropped any URL a reply carried.
An origin now appends its horizon-history-url setting when set. The value rides the pragma as one raw card token, so SetConfig refuses anything but a single http or https URL with a host and no white space or credentials, and the handler emits nothing for a value stored past that check. The client records a valid URL from any origin in its clone and sync results, exported additively on the public results, and the CLI's clone and cone store/deepen print it. (user: [email protected], size: 1757) [annotate] [blame] [check-ins using] [more...]
package conformance import ( "net/http/httptest" "os" "path/filepath" "strings" "testing" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/repo" ) // TestZitHorizonHistoryURLInterop runs zit's horizon clone and pull against // go-libfossil's handler naming a history URL in horizon-served // (draft-fossil-horizon-00 §6.2.5): zit takes the level past the optional // URL and keeps its horizon. zit names no URL of its own. func TestZitHorizonHistoryURLInterop(t *testing.T) { bin := zitHorizonBinary(t) dir := t.TempDir() home := filepath.Join(dir, "home") if err := os.Mkdir(home, 0o755); err != nil { t.Fatal(err) } g := newHZSyncGraph(t) const url = "https://example.org/history" if err := g.f.r.SetConfig(repo.SettingHorizonHistoryURL, url); err != nil { t.Fatal(err) } c := hzUUID(t, g.f.r, g.c3) origin := &hzRecorder{r: g.f.r} server := httptest.NewServer(origin) defer server.Close() zhorizon := filepath.Join(dir, "zhorizon") zitRun(t, bin, home, dir, "clone", "--no-open", "--horizon="+c, server.URL, zhorizon) hzCommit(t, g.f, "c5", []libfossil.FslID{g.m}, nil) zitRun(t, bin, home, zhorizon, "pull") served := 0 for i, e := range origin.take() { for _, values := range hzPragmas(e.reply, "horizon-served") { if strings.Join(values, " ") != "content "+url { t.Fatalf("reply %d to zit carries horizon-served %q", i, values) } served++ } } if served == 0 { t.Fatal("no reply to zit's horizon clone and pull named the history URL") } if got := zitElidedCount(t, zitRun(t, bin, home, zhorizon, "verify")); got != len(g.below) { t.Fatalf("zit's horizon store elided %d, want %d: it did not keep its horizon", got, len(g.below)) } }