From fb0c18b4fd0829e0621538956ea3871254860875 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 12:05:18 +0200 Subject: [PATCH] SignatureTests: decay test uses sources nothing rewrites (the item-swap mutant survived the first fixture) Mutant decay-item-from-last-entry survived dc244686: the gun was the last-inserted entry, so Values.Last().Item was its own, and every other entry was rewritten by its Execute after the decay loop. The fixture now stops the drive and pings once, so the gun, the drive and the ping are touched by decay alone and their three items differ. Builds. Co-Authored-By: Claude Opus 5.5 --- tests/Aetheria.Shared.Tests/SignatureTests.cs | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/SignatureTests.cs b/tests/Aetheria.Shared.Tests/SignatureTests.cs index 46e75e0a7..066be454b 100644 --- a/tests/Aetheria.Shared.Tests/SignatureTests.cs +++ b/tests/Aetheria.Shared.Tests/SignatureTests.cs @@ -363,28 +363,38 @@ public sealed class SignatureTests : IDisposable Assert.False(r.Ship.VisibilitySources.ContainsKey(r.Weapon), "a signature below 0.1 is gone"); } - // Decay rebuilds every entry from its own: with a gun, a drive and two Visibility gears all decaying together, - // each entry still names the item of the source that wrote it (and the hull's names none). + // Decay rebuilds every entry from its own. A gun, a drive that has stopped burning and a sensor that has pinged + // each wrote once and are never rewritten, so after a long tick the only thing touching them is decay; each + // still names the item of the source that wrote it, and the three items differ. [Fact] public void DecayKeepsEachSourcesOwnItem() { - var r = Build(Armament.Gun, .5f, Drive(10), - new VisibilityData { Visibility = Constant(40), VisibilityDecay = Constant(0), Channel = SignatureChannel.Emission }, - new VisibilityData { Visibility = Constant(30), VisibilityDecay = Constant(0), Channel = SignatureChannel.Reflection }); + var r = Build(Armament.Gun, .5f, Drive(10), new SensorData + { + Sensitivity = Constant(3f), PingBoost = Constant(.02f), PingEnergy = Constant(0f), PingVisibility = Constant(5f), + PingRange = Constant(300f), PingCooldown = Constant(4f) + }); var thruster = Single(r.Ship); + var sensor = Single(r.Ship); thruster.Item.UpdatePerformance(); Burn(r, 1f); + Burn(r, 0f); // the drive stops: its entry is no longer rewritten + sensor.Ping(); Fire(r); - var itemed = r.Ship.VisibilitySources.Where(kv => kv.Key is Behavior).ToArray(); - Assert.Equal(4, itemed.Length); - Assert.Equal(4, itemed.Select(kv => kv.Value.Item).Distinct().Count()); + var sources = new Behavior[] { thruster, sensor, r.Weapon }; + var before = sources.Select(b => Of(r.Ship, b)).ToArray(); + Assert.Equal(3, before.Select(e => e.Item).Distinct().Count()); + Assert.All(before, e => Assert.True(e.Strength > 1f, "fixture: each source has a live entry")); r.Zone.Update(1f); - var after = r.Ship.VisibilitySources.Where(kv => kv.Key is Behavior).ToArray(); - Assert.Equal(4, after.Length); - foreach (var kv in after) Assert.Same(((Behavior) kv.Key).Item, kv.Value.Item); - Assert.All(r.Ship.VisibilitySources.Where(kv => kv.Key is Entity), kv => Assert.Null(kv.Value.Item)); + for (var i = 0; i < sources.Length; i++) + { + var after = Of(r.Ship, sources[i]); + Assert.True(after.Strength < before[i].Strength, "fixture: decay touched the entry"); + Assert.Same(sources[i].Item, after.Item); + Assert.Equal(before[i].Channel, after.Channel); + } } // ---- APlumeKeepsTheLargerBurn ----