From b945e4e177d3ada1817ac7b0b744a6e5df158672 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 9 Jul 2026 20:30:46 +0100 Subject: [PATCH] Prove Aetheria EveUnity receipt bridge --- .../Tests/DaemonRuntimeDocumentTests.cs | 103 ++++++++++++++++++ Assets/Scripts/Tests/Tests.asmdef | 4 +- 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index ba1255f69..335d7a67d 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -1,5 +1,7 @@ using CultMath; +using GameCult.Aetheria.EveRuntime; using GameCult.Aetheria.State.Verse; +using GameCult.Eve.UnityScene; using GameCult.Mesh; using NUnit.Framework; using System; @@ -2755,6 +2757,107 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(AetheriaRuntimeDaemonCommandKinds.SensorPing, envelope.Kind); } + [Test] + public void EveUnitySceneProviderBridgePublishesProviderReceiptForDaemonCommand() + { + var statePath = Path.Combine( + Path.GetTempPath(), + "aetheria-eveunity-scene-receipt-tests", + Path.GetRandomFileName(), + "state.cc"); + var frame = AetheriaRuntimeDaemonFrameDocument.Create( + new AetheriaRuntimeRunCheckpointCommit + { + CurrentEntityKey = "entity:surface-player" + }, + "aetheria-daemon", + "session-scene-receipt", + 80, + 1.5, + 0.02); + PublishLatestFrameThroughVerseClient(statePath, frame); + + using var client = AetheriaClient + .OpenAsync(statePath, "unity-scene-receipt-test", startServer: false, pullOnOpen: true) + .GetAwaiter() + .GetResult(); + var stateBoot = new AetheriaRuntimeStateBootReport( + "", + "", + "state-path-override", + "Aetheria daemon test", + "aetheria.local", + "unity-scene-receipt-test", + "", + statePath, + "", + stateFileExists: true, + supportsLocalStateFileRead: true, + "", + Array.Empty(), + Array.Empty(), + "", + "", + "", + ""); + var previousResolveStateBoot = AetheriaEveRuntimeUnityHooks.ResolveStateBoot; + var previousRuntimeState = AetheriaEveRuntimeUnityHooks.RuntimeState; + var previousControl = AetheriaEveRuntimeUnityHooks.Control; + var previousUi = AetheriaEveRuntimeUnityHooks.Ui; + var previousStateRefResolver = AetheriaEveRuntimeUnityHooks.StateRefResolver; + + try + { + AetheriaEveRuntimeUnityHooks.ResolveStateBoot = _ => stateBoot; + AetheriaEveRuntimeUnityHooks.RuntimeState = (_, __) => client.State; + AetheriaEveRuntimeUnityHooks.Control = (_, __) => client.Control; + AetheriaEveRuntimeUnityHooks.Ui = (_, __) => client.Ui; + AetheriaEveRuntimeUnityHooks.StateRefResolver = (_, __) => + client.State.CreateEveSurfaceCultMeshStateRefResolver(); + + using var bridge = new AetheriaEveUnitySceneProviderBridge( + statePath, + AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, + "unity-scene-receipt-test"); + EveUnitySceneCommandReceipt observedReceipt = null; + bridge.ReceiptAvailable += receipt => observedReceipt = receipt; + var request = new EveSurfaceCommandRequest( + "aetheria.daemon", + AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, + CultMesh.OperationInvocation("aetheria.daemon.commands.SensorPing"), + CultMesh.OperationPayload(), + DateTimeOffset.Parse("2026-07-09T00:00:00Z"), + "", + "aetheria.daemon.commands", + "aetheria.eve_command_acceptance_status.v1"); + + bridge.Submit(request); + + Assert.IsNotNull(observedReceipt); + Assert.AreEqual("accepted", observedReceipt.State); + Assert.AreEqual("Aetheria", observedReceipt.OwnerRepo); + Assert.AreEqual("aetheria-daemon-command-boundary", observedReceipt.Authority); + Assert.AreEqual("aetheria.daemon", observedReceipt.ProviderId); + Assert.AreEqual(AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, observedReceipt.SurfaceId); + Assert.AreEqual( + AetheriaRuntimeDaemonOperationIds.ForKind(AetheriaRuntimeDaemonCommandKinds.SensorPing), + observedReceipt.Command); + Assert.IsFalse(string.IsNullOrWhiteSpace(observedReceipt.CommandId)); + Assert.AreEqual(observedReceipt.CommandId, observedReceipt.ReceiptId); + Assert.AreEqual("aetheria.eve_command_acceptance_status.v1", observedReceipt.Schema); + Assert.IsTrue(observedReceipt.IsProviderOwned); + Assert.IsTrue(observedReceipt.ShouldRefreshProviderSurface); + } + finally + { + AetheriaEveRuntimeUnityHooks.ResolveStateBoot = previousResolveStateBoot; + AetheriaEveRuntimeUnityHooks.RuntimeState = previousRuntimeState; + AetheriaEveRuntimeUnityHooks.Control = previousControl; + AetheriaEveRuntimeUnityHooks.Ui = previousUi; + AetheriaEveRuntimeUnityHooks.StateRefResolver = previousStateRefResolver; + } + } + [Test] public void DaemonEveSurfaceCommandRejectsUnsupportedArgumentlessOperation() { diff --git a/Assets/Scripts/Tests/Tests.asmdef b/Assets/Scripts/Tests/Tests.asmdef index f07f01bdd..09663af15 100644 --- a/Assets/Scripts/Tests/Tests.asmdef +++ b/Assets/Scripts/Tests/Tests.asmdef @@ -7,10 +7,12 @@ "Unity.Mathematics", "CultMath", "Aetheria.Shared.Unity", + "GameCult.Aetheria.EveRuntime", "GameCult.Aetheria.State.Unity", "GameCult.Caching", "GameCult.Mesh", - "GameCult.Eve.Surface" + "GameCult.Eve.Surface", + "GameCult.Eve.UnityScene" ], "includePlatforms": [ "Editor"