Networking tests: order is data, so pin each change's own publication, not its delivery order
The salvaged S1 and in-place re-upsert tests also asserted the delivery order of the rejected drainer. Under Q-P1 A delivery order across threads and a nested write's depth-first delivery are not guaranteed; each change is published once with its own context, and wire peers drop stale changes by Sequence (Cut 6). Both assertions now say exactly that. The journal tests' reentrant-write recorder subscribes before the handler that writes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fe7bca0cb5
commit
3fb2613abf
2 changed files with 7 additions and 3 deletions
|
|
@ -303,9 +303,9 @@ namespace GameCult.Networking.Tests
|
|||
var database = Database(cache, primary: true, store);
|
||||
var message = database.Documents.CreateRawDocumentPutMessage(
|
||||
"reentrant-two", new CultRecordHandle<NetworkSchemaNote>(Two), Note("two"));
|
||||
var published = Record(database);
|
||||
database.Watch<NetworkSchemaNote>().Where(change => change.Key.Equals(One)).Subscribe(_ =>
|
||||
database.ApplyPutAsync(message).GetAwaiter().GetResult());
|
||||
var published = Record(database);
|
||||
|
||||
await database.PutAsync(One, Note("one"));
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,9 @@ namespace GameCult.Networking.Tests
|
|||
Assert.That(cache.Get<NetworkSchemaNote>(key)!.Text, Is.EqualTo("B"), "the cache admitted A then B");
|
||||
Assert.That(TextOf(last.Document), Is.EqualTo("B"), "the log's last write for the key must be the cache's last write");
|
||||
Assert.That(replicaCache.Get<NetworkSchemaNote>(key)?.Text, Is.EqualTo("B"), "a replica built from the log must match the primary");
|
||||
Assert.That(seen.Last(), Is.EqualTo("B"), "a subscriber's final state for the key");
|
||||
// Delivery is not ordered across threads (order is data: a wire peer drops the stale change by Sequence, Cut 6),
|
||||
// so a subscriber sees both changes, once each, in either order.
|
||||
Assert.That(seen, Is.EquivalentTo(new[] { "A", "B" }), "each change is published exactly once");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +338,9 @@ namespace GameCult.Networking.Tests
|
|||
await database.PutPredictedAsync(key, Note("predicted"));
|
||||
await database.ApplyPutAsync(message);
|
||||
|
||||
Assert.That(seen, Is.EqualTo(new (CultNetDatabaseChangeKind, string?)[]
|
||||
// The observer's nested write is delivered depth-first, inside the delivery of the change that caused it, so
|
||||
// the database may publish the two in either order; what is pinned is that each carries its own context.
|
||||
Assert.That(seen, Is.EquivalentTo(new (CultNetDatabaseChangeKind, string?)[]
|
||||
{
|
||||
(CultNetDatabaseChangeKind.Predicted, null),
|
||||
(CultNetDatabaseChangeKind.Reconciled, "predicted"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue