carlos / platform Public

host tests: fixtures write what production writes

The backdated canary pointer now names its account, as signPointer
always does (an unbound pointer is refused on read since H3-M8). The
lifetime fold puts each edges-file body at its own box's key, as
edgesFileWriteClaims does, instead of fixed annie/betty keys the
H3-M4 body/key binding rightly refuses.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c1e41bfd9306eac2047bdc4a62dafd94a9f95360 parent 4717e16
2 files changed, +27 −9
  • internal/host/host_test.go +5 −2
  • internal/host/movesoffline_lifetime_test.go +22 −7
diff --git a/internal/host/host_test.go b/internal/host/host_test.go
index 0a822952a..5b4b90dd3 100644
--- a/internal/host/host_test.go
+++ b/internal/host/host_test.go
@@ -1493,16 +1493,19 @@ type wireWrapper struct {
// writeBackdatedPointer signs and writes a channel pointer with an
// arbitrary PromotedAt directly to key release.ChannelKey(acct, app,
-// channel), bypassing Promote's clock stamp.
+// channel), bypassing Promote's clock stamp. It names its account, as every
+// pointer signPointer writes does: one without is refused on read (hunt
+// H3-M8, release.ErrPointerUnbound).
func writeBackdatedPointer(t *testing.T, s release.Store, priv ed25519.PrivateKey, acct, app, channel, version string, promotedAt time.Time) {
t.Helper()
p := struct {
Schema int `json:"schema"`
+ Account string `json:"account"`
App string `json:"app"`
Channel string `json:"channel"`
Version string `json:"version"`
PromotedAt time.Time `json:"promoted_at"`
- }{Schema: 1, App: app, Channel: channel, Version: version, PromotedAt: promotedAt}
+ }{Schema: 1, Account: acct, App: app, Channel: channel, Version: version, PromotedAt: promotedAt}
payload, err := json.Marshal(p)
if err != nil {
t.Fatalf("marshal backdated pointer: %v", err)
diff --git a/internal/host/movesoffline_lifetime_test.go b/internal/host/movesoffline_lifetime_test.go
index 7e2ac4df1..eb74e0605 100644
--- a/internal/host/movesoffline_lifetime_test.go
+++ b/internal/host/movesoffline_lifetime_test.go
@@ -77,16 +77,31 @@ func requirePublished(t *testing.T, why string, body []byte, want registry.Pair)
}
// requireFoldWinner folds two edges-file bodies through the real edge fold
-// as edgeSelf sees them, once with each in the first file position, and
-// requires want's box to win the host's dial both times.
+// as edgeSelf sees them, and requires want's box to win the host's dial.
+// Each body sits at the key of the box it names, as the production writer
+// puts it (edgesFileWriteClaims takes both from one ident.Box), since the
+// edge refuses a body its key does not name (hunt H3-M4). The fold sorts
+// by key, so a body's file position is its box's name: across the callers
+// the winner sorts first (ie-box over uk-box, uk-a over uk-b) and last
+// (uk-box over ie-box, uk-a over ie-box).
func requireFoldWinner(t *testing.T, why string, a, b []byte, want string) {
t.Helper()
- for _, order := range [][2][]byte{{a, b}, {b, a}} {
- files := map[string][]byte{edgesFileKey("annie"): order[0], edgesFileKey("betty"): order[1]}
- box, ok, err := edge.FoldedHome(files, edgeSelf, offHost)
- if err != nil || !ok || box != want {
- t.Fatalf("%s: the fold chose %q (dial %v, %v), want %s", why, box, ok, err, want)
+ files := map[string][]byte{}
+ for _, body := range [][]byte{a, b} {
+ var f struct {
+ Box string `json:"box"`
}
+ if err := json.Unmarshal(body, &f); err != nil || f.Box == "" {
+ t.Fatalf("%s: a publication names no box (%v)", why, err)
+ }
+ if _, dup := files[edgesFileKey(f.Box)]; dup {
+ t.Fatalf("%s: both publications are %s's; a fold reads one file per box", why, f.Box)
+ }
+ files[edgesFileKey(f.Box)] = body
+ }
+ box, ok, err := edge.FoldedHome(files, edgeSelf, offHost)
+ if err != nil || !ok || box != want {
+ t.Fatalf("%s: the fold chose %q (dial %v, %v), want %s", why, box, ok, err, want)
}
}