diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/VirtualTags/VirtualTagHostActorTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/VirtualTags/VirtualTagHostActorTests.cs index 3b759cf70..9b0d669b1 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/VirtualTags/VirtualTagHostActorTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/VirtualTags/VirtualTagHostActorTests.cs @@ -147,9 +147,16 @@ public sealed class VirtualTagHostActorTests : RuntimeActorTestBase mux.ExpectMsg(TimeSpan.FromSeconds(5)); // Re-apply with the same plan — host should see vt-1 absent from _children and spawn fresh. - host.Tell(new VirtualTagHostActor.ApplyVirtualTags(plan)); - var reg2 = mux.ExpectMsg(TimeSpan.FromSeconds(5)); - reg2.TagRefs.ShouldContain("a"); + // The test saw the child die, but the host's own Terminated (which prunes _children) can land + // after a single re-apply, which then still sees vt-1 as present and spawns nothing + // (lmxopcua#769: this raced ~1 in 6 full runs). Re-apply until the host has pruned it. + DependencyMuxActor.RegisterInterest? reg2 = null; + AwaitAssert(() => + { + host.Tell(new VirtualTagHostActor.ApplyVirtualTags(plan)); + reg2 = mux.ExpectMsg(TimeSpan.FromMilliseconds(500)); + }, TimeSpan.FromSeconds(10), TimeSpan.FromMilliseconds(50)); + reg2!.TagRefs.ShouldContain("a"); // The new child must be a different actor ref than the one we killed. var secondChild = mux.LastSender;