From 4f632fbf4616b6018af88cd15f02090a4b93df55 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 29 Sep 2026 08:42:32 +0200 Subject: [PATCH] Drive the hop-subscription test through the database write path Batch commits on the cache do not reach the database's change stream, so the subscriber's citers were written with database.PutAsync; the variant goes in through UpsertVariantAsync. On the previous source the second subscriber stops receiving after the variant exists (red); it now keeps receiving. Co-Authored-By: Claude Sonnet 5 --- .../CultNetDocumentRegistryVariantTests.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/GameCult.Networking.Tests/CultNetDocumentRegistryVariantTests.cs b/tests/GameCult.Networking.Tests/CultNetDocumentRegistryVariantTests.cs index 2ae6dfab..7aeadc15 100644 --- a/tests/GameCult.Networking.Tests/CultNetDocumentRegistryVariantTests.cs +++ b/tests/GameCult.Networking.Tests/CultNetDocumentRegistryVariantTests.cs @@ -243,13 +243,16 @@ namespace GameCult.Networking.Tests }); await WaitUntilAsync(() => snapshots.Count == 1, Diagnostic); - cache.Commit(batch => batch.UpsertVariant(VariantKey, BaseKey, new[] + await database.PutAsync(new CultRecordKey("citer-two"), Citer("citer-two", BaseKey)); + await WaitUntilAsync(() => changes.Any(change => change.SubscriptionId == "citers" && change.Document?.RecordKey == "citer-two"), Diagnostic); + + // With a variant in the store, the same subscriber keeps receiving. + await cache.UpsertVariantAsync(VariantKey, BaseKey, new[] { cache.Override(nameof(VariantWireFixture.Name), "big") - })); - cache.Commit(batch => batch.Upsert(typeof(VariantCiterFixture), Citer("citer-two", BaseKey), new CultRecordKey("citer-two"))); - - await WaitUntilAsync(() => changes.Any(change => change.SubscriptionId == "citers" && change.Document?.RecordKey == "citer-two"), Diagnostic); + }); + await database.PutAsync(new CultRecordKey("citer-three"), Citer("citer-three", BaseKey)); + await WaitUntilAsync(() => changes.Any(change => change.SubscriptionId == "citers" && change.Document?.RecordKey == "citer-three"), Diagnostic); Assert.That(errors, Is.Empty, "a subscriber that never selects the variant is never told about it"); // "cited": wire rows some citer cites. Once a citer cites the variant, it selects it. @@ -266,15 +269,15 @@ namespace GameCult.Networking.Tests }); await WaitUntilAsync(() => snapshots.Count == 2, Diagnostic); Assert.That(errors, Is.Empty, "only the base is cited yet"); - cache.Commit(batch => batch.Upsert(typeof(VariantCiterFixture), Citer("citer-three", VariantKey), new CultRecordKey("citer-three"))); + await database.PutAsync(new CultRecordKey("citer-four"), Citer("citer-four", VariantKey)); await WaitUntilAsync(() => errors.Any(error => error.Error.Contains(VariantKey.Value)), Diagnostic); Assert.That(changes.Where(change => change.SubscriptionId == "cited").Select(change => change.Document?.RecordKey), Does.Not.Contain(VariantKey.Value), "a variant never reaches a subscriber as a record"); // The first subscriber is still alive after the refusal. - cache.Commit(batch => batch.Upsert(typeof(VariantCiterFixture), Citer("citer-four", BaseKey), new CultRecordKey("citer-four"))); - await WaitUntilAsync(() => changes.Any(change => change.SubscriptionId == "citers" && change.Document?.RecordKey == "citer-four"), Diagnostic); + await database.PutAsync(new CultRecordKey("citer-five"), Citer("citer-five", BaseKey)); + await WaitUntilAsync(() => changes.Any(change => change.SubscriptionId == "citers" && change.Document?.RecordKey == "citer-five"), Diagnostic); } finally {