From 9f20d1be2ab560d85c26a25ae7164487b4af518a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 14 Oct 2026 21:54:49 +0200 Subject: [PATCH] PythonWrittenStoreTests: the replaced-record test swaps the record's bytes in the file The py record is undeclared by LeafRecord (read-only), so a second cache cannot rewrite it. Co-Authored-By: Claude Sonnet 5.5 --- .../GameCult.Caching.Tests/PythonWrittenStoreTests.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/GameCult.Caching.Tests/PythonWrittenStoreTests.cs b/tests/GameCult.Caching.Tests/PythonWrittenStoreTests.cs index e20fe926..9ee8a8bc 100644 --- a/tests/GameCult.Caching.Tests/PythonWrittenStoreTests.cs +++ b/tests/GameCult.Caching.Tests/PythonWrittenStoreTests.cs @@ -115,11 +115,12 @@ namespace GameCult.Caching.Tests var path = Store("leaf-record.cc", scratch); var (reader, readerStore) = await PulledAsync(path); - var (writer, writerStore) = await PulledAsync(path); - var py = writer.AllEntries.OfType().Single(record => record.Id == "py"); - py.Items.Clear(); - await writer.AddAsync(py); - writerStore.PushAll(); + // Another writer replaces the record with one that holds no id. + var snapshot = CultDocumentMessagePackSerialization.DeserializeSnapshot(File.ReadAllBytes(path)); + var replaced = snapshot.Records.Single(record => record.Key == "py"); + replaced.Payload = CultDocumentMessagePackSerialization.SerializeUntyped( + new NumericLeafVectorTests.LeafRecord { Id = "py" }, typeof(NumericLeafVectorTests.LeafRecord)); + File.WriteAllBytes(path, CultDocumentMessagePackSerialization.SerializeSnapshot(snapshot)); Assert.That(HeaderOf(path), Is.EqualTo(CultPersistedStoreSnapshot.FormatV1), "the replacement holds no id"); await reader.AddAsync(new NumericLeafVectorTests.LeafRecord { Id = "other" });