test(storage): a page changed at open holds the header's G

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-30 10:25:53 -08:00
1 parent 6a68f7bb86
commit 40c4e1ac8e
1 file changed
+18
@@ -391,3 +391,21 @@ func TestRecordRuntimeCopiesItsInputs(t *testing.T) {
t.Fatal("the caller's slice changed the runtime's state without the kernel")
}
}
// A page whose chunks were judged changed at open is not current on disk: G
// does not pass it until it is written again.
func TestRecordRuntimeAPageChangedAtOpenHoldsG(t *testing.T) {
pos := uint64(20)
kinds := []chunkkernel.Kind{chunkkernel.Unknown, chunkkernel.Absent} // disk said HP for chunk 0
r, err := newChunkRecordRuntime(filepath.Join(t.TempDir(), "rec"), 2, 7, func() uint64 { return pos },
kinds, make([][32]byte, 2), []uint64{10}, 10)
if err != nil {
t.Fatal(err)
}
if err := r.WriteDue(time.Now()); err != nil {
t.Fatal(err)
}
if h, err := readChunkRecordHeader(r.dir); err == nil && h.G > 10 {
t.Fatalf("header G %d passed a page changed at open and not yet written (valid through 10)", h.G)
}
}