database_change_raw: a C#-written two-change commit vector (commitId, commitCount 2), walked by cultnet-py
All checks were successful
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 22m20s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 51s
All checks were successful
CultMesh QUIC native / Build win32-x64 (pull_request) Has been skipped
CultMesh QUIC native / Build linux-x64 (pull_request) Has been skipped
CultMesh QUIC native / Release native binaries (pull_request) Has been skipped
CultMesh portability and performance / ubuntu-latest reactive semantics and leases (pull_request) Successful in 22m20s
CultMesh QUIC native / Verify committed binaries match SHA256SUMS (pull_request) Successful in 51s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8177fa9c21
commit
3ee84eb9c5
4 changed files with 52 additions and 19 deletions
|
|
@ -225,6 +225,39 @@ namespace GameCult.Networking.Tests
|
|||
Assert.That(run.Faults, Has.Count.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ATwoChangeCommitIsWrittenAsTheVectorOtherRuntimesDecode()
|
||||
{
|
||||
// tests/vectors/database-change-commit/two-change-commit.msgpack: the two change messages of one commit, as the C#
|
||||
// serializer writes them, concatenated. Written with CULTCACHE_WRITE_VECTORS=1; every other run compares bytes.
|
||||
var commit = Enumerable.Range(0, 2).Select(index => new CultNetDatabaseChangeRawMessage
|
||||
{
|
||||
MessageId = $"change-{index}",
|
||||
SubscriptionId = "sub-1",
|
||||
ChangeKind = "removed",
|
||||
RecordKey = index == 0 ? "note:a" : "note:b",
|
||||
SchemaId = "schema-note",
|
||||
CommitId = "9f1c0f0e4b7a4c1f9d2e",
|
||||
CommitCount = 2
|
||||
});
|
||||
var bytes = commit.SelectMany(message => CultNetSchemaMessageSerialization.Serialize(message)).ToArray();
|
||||
|
||||
var directory = TestContext.CurrentContext.TestDirectory;
|
||||
while (directory != null && !System.IO.Directory.Exists(System.IO.Path.Combine(directory, "tests", "vectors")))
|
||||
directory = System.IO.Path.GetDirectoryName(directory);
|
||||
Assert.That(directory, Is.Not.Null, "tests/vectors is above the test directory");
|
||||
var path = System.IO.Path.Combine(directory!, "tests", "vectors", "database-change-commit", "two-change-commit.msgpack");
|
||||
if (Environment.GetEnvironmentVariable("CULTCACHE_WRITE_VECTORS") == "1")
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)!);
|
||||
System.IO.File.WriteAllBytes(path, bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
Assert.That(System.IO.File.Exists(path), Is.True, "the vector is committed");
|
||||
Assert.That(Convert.ToHexString(bytes), Is.EqualTo(Convert.ToHexString(System.IO.File.ReadAllBytes(path))));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnOlderPeerReadsTheChangeAndIgnoresTheCommitFields()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue