Carrier vectors: drop the derived hasHop member from the reference's expected JSON

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Libby 2026-11-07 01:39:57 +00:00
commit 51941fa61b
2 changed files with 22 additions and 9 deletions

View file

@ -16,8 +16,7 @@
"projection": "header",
"descending": false,
"limit": null,
"cursor": null,
"hasHop": false
"cursor": null
},
"shardId": null,
"shardEpoch": null
@ -70,8 +69,7 @@
"projection": "document",
"descending": true,
"limit": 200,
"cursor": "opaque-cursor",
"hasHop": true
"cursor": "opaque-cursor"
},
"shardId": "shard-1",
"shardEpoch": 7
@ -94,8 +92,7 @@
"projection": "header",
"descending": false,
"limit": null,
"cursor": null,
"hasHop": false
"cursor": null
},
"includeSnapshot": true,
"consumerRuntimeId": null,
@ -151,8 +148,7 @@
"projection": "document",
"descending": true,
"limit": 200,
"cursor": "opaque-cursor",
"hasHop": true
"cursor": "opaque-cursor"
},
"includeSnapshot": false,
"consumerRuntimeId": "consumer",

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using MessagePack;
using NUnit.Framework;
@ -120,10 +121,26 @@ namespace GameCult.Networking.Tests
name,
schemaVersion = message.SchemaVersion,
messagePackBase64 = Convert.ToBase64String(bytes),
expected = JsonSerializer.SerializeToElement(message, message.GetType(), JsonOptions)
expected = WithoutDerivedMembers(JsonSerializer.SerializeToNode(message, message.GetType(), JsonOptions))
};
}
// CultNetSelection.HasHop is an [IgnoreMember] convenience, not wire; System.Text.Json would emit it.
private static JsonNode? WithoutDerivedMembers(JsonNode? node)
{
switch (node)
{
case JsonObject obj:
obj.Remove("hasHop");
foreach (var child in obj.Select(pair => pair.Value).ToArray()) WithoutDerivedMembers(child);
break;
case JsonArray array:
foreach (var child in array) WithoutDerivedMembers(child);
break;
}
return node;
}
private static string VectorPath()
{
var directory = new DirectoryInfo(TestContext.CurrentContext.TestDirectory);