Pin the legacy-layout and missing-header refusals
The legacy catalog layout reaches CultMesh's fallback reader, and a nil header was the only defaulted header; each gets one vector or test. The C# store tests catch the refusal where the store attaches. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
36aa8d8791
commit
66bd07b941
4 changed files with 33 additions and 9 deletions
|
|
@ -97,7 +97,7 @@ namespace GameCult.Caching.Tests
|
|||
throw new FileNotFoundException($"Shared vector {name} not found above {TestContext.CurrentContext.TestDirectory}.");
|
||||
}
|
||||
|
||||
private static async Task<string> PullRefusalAsync(string vector)
|
||||
private static string Refusal(string vector)
|
||||
{
|
||||
var root = Path.Combine(Path.GetTempPath(), $"cultlib-vector-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(root);
|
||||
|
|
@ -106,8 +106,7 @@ namespace GameCult.Caching.Tests
|
|||
var file = Path.Combine(root, "store.msgpack");
|
||||
File.Copy(VectorPath(vector), file);
|
||||
using var cache = new CultCache();
|
||||
cache.AddBackingStore(new SingleFileMessagePackBackingStore(file));
|
||||
var error = Assert.CatchAsync(async () => await cache.PullAllBackingStoresAsync());
|
||||
var error = Assert.Catch(() => cache.AddBackingStore(new SingleFileMessagePackBackingStore(file)));
|
||||
Assert.That(error, Is.Not.Null);
|
||||
Assert.That(error!.ToString(), Does.Contain(nameof(NotSupportedException)));
|
||||
return error.ToString();
|
||||
|
|
@ -119,26 +118,36 @@ namespace GameCult.Caching.Tests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public async Task SingleFileRefusesUnknownHeaderByName()
|
||||
public void SingleFileRefusesUnknownHeaderByName()
|
||||
{
|
||||
Assert.That(await PullRefusalAsync("unknown-header.msgpack"), Does.Contain("cultcache.store.v9"));
|
||||
Assert.That(Refusal("unknown-header.msgpack"), Does.Contain("cultcache.store.v9"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SingleFileRefusesExtraRecordSlotNamingTheRecord()
|
||||
public void SingleFileRefusesExtraRecordSlotNamingTheRecord()
|
||||
{
|
||||
var message = await PullRefusalAsync("extra-slot-full-payload.msgpack");
|
||||
var message = Refusal("extra-slot-full-payload.msgpack");
|
||||
Assert.That(message, Does.Contain("item:anvil"));
|
||||
Assert.That(message, Does.Contain(ItemSchemaId));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SingleFileRefusesVariantStoreByVersionOrRecord()
|
||||
public void SingleFileRefusesVariantStoreByVersionOrRecord()
|
||||
{
|
||||
Assert.That(await PullRefusalAsync("variant-v2.msgpack"),
|
||||
Assert.That(Refusal("variant-v2.msgpack"),
|
||||
Does.Contain("cultcache.store.v2").Or.Contain("item:anvil-big"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SnapshotWithoutAFormatVersionIsRefusedNotDefaultedToV1()
|
||||
{
|
||||
// [nil, [], []]
|
||||
var bytes = new byte[] { 0x93, 0xc0, 0x90, 0x90 };
|
||||
|
||||
Assert.That(() => CultDocumentMessagePackSerialization.DeserializeSnapshot(bytes),
|
||||
Throws.TypeOf<NotSupportedException>().With.Message.Contains("format version"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void V1StoreWrittenAtTheBaseCommitStillDecodesByteForByte()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@ public sealed class CultMeshVariantRefusalTests
|
|||
message.Should().Contain("item:anvil").And.Contain(ItemSchemaId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadSingleFileDocument_RefusesExtraRecordSlotInTheLegacyCatalogLayoutToo()
|
||||
{
|
||||
var message = Refusal("legacy-catalog-extra-slot.msgpack").Message;
|
||||
message.Should().Contain("item:anvil").And.Contain(ItemSchemaId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadSingleFileDocument_RefusesVariantStoreByVersionOrRecord()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ at test time. Run: python generate.py (needs msgpack).
|
|||
|
||||
unknown-header.msgpack header cultcache.store.v9, otherwise the v1 store
|
||||
extra-slot-full-payload.msgpack v1 header, record item:anvil gains slot 4, payload stays full
|
||||
legacy-catalog-extra-slot.msgpack
|
||||
v1 header, catalog entry in the older layout (contentHash at slot
|
||||
5), so CultMesh's legacy snapshot reader takes it, plus the
|
||||
extra-slot record
|
||||
v1-base.msgpack NOT generated here: written once by the Python runtime at CultLib
|
||||
69a21bb (SingleFileMessagePackBackingStore.push of alpha and
|
||||
beta, type vectors.item, before any C0 code existed)
|
||||
|
|
@ -32,3 +36,6 @@ write("extra-slot-full-payload.msgpack",
|
|||
[header, catalog, [anvil + [["item:bellows", []]]] + records[1:]])
|
||||
variant = ["item:anvil-big", anvil[1], anvil[2], b"", ["item:anvil", [[0, [[1, ""]], "", 99]]]]
|
||||
write("variant-v2.msgpack", ["cultcache.store.v2", catalog, records + [variant]])
|
||||
legacy_entry = [catalog[0][0], catalog[0][1], catalog[0][2], catalog[0][4], None, catalog[0][3], []]
|
||||
write("legacy-catalog-extra-slot.msgpack",
|
||||
[header, [legacy_entry], [anvil + [["item:bellows", []]]]])
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
“²cultcache.store.v1‘—ÙGsha256:88d3fdf0a927acf3b163940d8f8c7fe62b3316542ce771a67ec8bc038f594788µfixtures.precut2.item¸fixtures.precut2.item.v1Úp{"schemaName":"fixtures.precut2.item","schemaVersion":"fixtures.precut2.item.v1","members":[{"slot":0,"name":"Name","type":"System.String","isReference":false,"many":false,"targetSchemaName":null,"indexAlias":null,"isName":true},{"slot":1,"name":"Count","type":"System.Int32","isReference":false,"many":false,"targetSchemaName":null,"indexAlias":null,"isName":false}]}ÀÙGsha256:dadf30bc920849ee89ed5d70cc73027070dd7571c5f878db1901f3abc459cc0c<30>‘•ªitem:anvilÙGsha256:88d3fdf0a927acf3b163940d8f8c7fe62b3316542ce771a67ec8bc038f594788Ù!2026-09-13T15:14:36.4032226+00:00Ä’¥anvil’¬item:bellows<77>
|
||||
Loading…
Reference in a new issue