From 5ecf2d9629e75d30c9c122ef51ac928904da172c Mon Sep 17 00:00:00 2001 From: thepra Date: Tue, 6 Oct 2026 19:41:22 +0200 Subject: [PATCH] The report tests read only the deliveries they queued ServiceReportTests looked at every delivery job of the last five minutes and read each body's actor. On the CI runner, slower than the workstation, other tests' jobs were still in that window, one of them without an actor, and four cases failed with a NullReferenceException. A test now sees only the jobs queued since it began, and checks the signer from the job itself. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw --- PrivaPub.Tests/Federation/ServiceReportTests.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PrivaPub.Tests/Federation/ServiceReportTests.cs b/PrivaPub.Tests/Federation/ServiceReportTests.cs index ea4ae34..466f31b 100644 --- a/PrivaPub.Tests/Federation/ServiceReportTests.cs +++ b/PrivaPub.Tests/Federation/ServiceReportTests.cs @@ -30,6 +30,8 @@ namespace PrivaPub.Tests.Federation { static readonly string[] PeerHosts = { "localhost", "127.0.0.1" }; + // (a test sees only the deliveries queued since it began: the others' share the database) + readonly DateTime _started = DateTime.UtcNow; Harness _harness; public async ValueTask InitializeAsync() @@ -74,10 +76,9 @@ namespace PrivaPub.Tests.Federation return post; } - async Task> Queued() => - (await DB.Default.Find().Match(j => j.Kind == JobKind.Deliver && j.CreatedAt >= DateTime.UtcNow.AddMinutes(-5)).ExecuteAsync(Token)) + async Task> Queued() => + (await DB.Default.Find().Match(j => j.Kind == JobKind.Deliver && j.CreatedAt >= _started).ExecuteAsync(Token)) .Select(j => JsonSerializer.Deserialize(j.Payload)) - .Select(p => (p, JsonNode.Parse(p.Body)!.AsObject())) .ToList(); // a community on a Lemmy, or on a server that takes reports as Lemmy does (the peer as localhost), and one of its posters there @@ -118,11 +119,12 @@ namespace PrivaPub.Tests.Federation Assert.Equal("a slur in the title", flag["summary"]!.GetValue()); Assert.Equal("a slur in the title", flag["content"]!.GetValue()); Assert.Empty(await _harness.Outgoing(poster.Id + "/inbox")); - Assert.DoesNotContain(await Queued(), q => q.Payload.Inbox != community.SharedInbox && q.Body.ToJsonString().Contains(post.ObjectURI)); + Assert.DoesNotContain(await Queued(), q => q.Inbox != community.SharedInbox && q.Body.Contains(post.ObjectURI)); Assert.DoesNotContain(alice.UserName, flag.ToJsonString()); Assert.DoesNotContain(alice.Id, flag.ToJsonString()); - var queued = Assert.Single(await Queued(), q => q.Body["actor"]!.GetValue() == reporter.Uri && q.Body["object"]!.GetValue() == post.ObjectURI); - Assert.Equal(LocalActorKind.Reporter, queued.Payload.SignerKind); + var queued = Assert.Single(await Queued(), q => q.Inbox == community.SharedInbox); + Assert.Equal(LocalActorKind.Reporter, queued.SignerKind); + Assert.Equal(reporter.Id, queued.SignerId); } [Fact]