From a78975244f20e62d72b0a3232aa9e100863e8159 Mon Sep 17 00:00:00 2001 From: Matthew Mattox Date: Sat, 14 Nov 2026 09:37:21 -0600 Subject: [PATCH] test: ignore the checksum in the snapshot descriptor round trip Since #140, bytes 26-27 and 32-35 hold the birth generation only with FlagHasTargetBirth. Without the flag, decoding ignores them and re-encoding writes zeros, so the checksum changes while every field stays the same. FuzzDecodeDescriptor compared the stored checksum too and failed on such descriptors; it now compares the fields. The input that found it is kept. Co-Authored-By: Claude Opus 5.5 --- internal/snapshot/snapshot_fuzz_test.go | 5 ++++- .../testdata/fuzz/FuzzDecodeDescriptor/8ac4626f92ad713e | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 internal/snapshot/testdata/fuzz/FuzzDecodeDescriptor/8ac4626f92ad713e diff --git a/internal/snapshot/snapshot_fuzz_test.go b/internal/snapshot/snapshot_fuzz_test.go index 3b167ffe..9ab2a7e6 100644 --- a/internal/snapshot/snapshot_fuzz_test.go +++ b/internal/snapshot/snapshot_fuzz_test.go @@ -71,7 +71,10 @@ func checkDescriptorDecode(t *testing.T, sector []byte, idx uint64) { if err != nil { t.Fatalf("decoding a re-encoded descriptor: %v", err) } + // Bytes only some formats use, such as the birth generation without + // FlagHasTargetBirth, re-encode as zero and change the checksum. + again.Checksum = desc.Checksum if *again != *desc { - t.Fatalf("descriptor changed after an encode/decode round trip") + t.Fatalf("descriptor changed after an encode/decode round trip: %+v != %+v", again, desc) } } diff --git a/internal/snapshot/testdata/fuzz/FuzzDecodeDescriptor/8ac4626f92ad713e b/internal/snapshot/testdata/fuzz/FuzzDecodeDescriptor/8ac4626f92ad713e new file mode 100644 index 00000000..cec162ce --- /dev/null +++ b/internal/snapshot/testdata/fuzz/FuzzDecodeDescriptor/8ac4626f92ad713e @@ -0,0 +1,3 @@ +go test fuzz v1 +[]byte("0000000000000000000000000A000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") +byte('\x00')