feat(tests): protocol dispatch test against canonical fixtures#12
Open
Taure wants to merge 1 commit into
Open
Conversation
Per-SDK protocol dispatch unit test: feeds every canonical server-emitted message envelope through AsobiRealtime.HandleMessage and asserts the matching SDK event fires. Vendors the 32-fixture corpus from asobi/priv/protocol/fixtures into Tests/Runtime/Resources/Fixtures. Audit findings against the canonical corpus turned up six dispatch cases that were silently falling through to the generic OnMatchEvent / OnWorldEvent buckets, plus session.heartbeat with no surfaced event. Added explicit handlers and events: match.finished -> OnMatchFinished match.matchmaker_expired -> OnMatchmakerExpired match.matchmaker_failed -> OnMatchmakerFailed world.finished -> OnWorldFinished world.list -> OnWorldList world.phase_changed -> OnWorldPhaseChanged session.heartbeat -> OnHeartbeat The defensive matchmaker.matched alias is kept as a fall-through to OnMatchmakerMatched with a TODO-deprecate note; removing without a deprecation cycle would break consumers that listened for it during the historical drift period. The alias is pinned by a dedicated test. Made HandleMessage internal and added a parameterless test-only ctor to allow exercising dispatch without a live WebSocket. Asobi.Tests already references Asobi via its asmdef; InternalsVisibleTo is wired through a new Runtime/AssemblyInfo.cs. The test also asserts the bidirectional invariant: every fixture has an Expected mapping and every Expected entry has a fixture, so future drift in either direction fails CI.
3 tasks
Contributor
Author
|
Heads up: #13 extracts the dispatch logic into a pure-C# This PR (#12) stays useful — it documents the Unity-side intent and will run the PlayMode coverage as soon as the secrets in #11 are provisioned. Both can land in either order; git handles the duplicate commit cleanly when one rebases over the other. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a per-SDK protocol dispatch unit test that feeds every canonical server-emitted message envelope through
AsobiRealtime.HandleMessageand asserts the matching SDK event fires. Catches doc-vs-server drift (silent missed callbacks) before any user reports it.The 32-fixture canonical corpus is vendored from
asobi/priv/protocol/fixturesintoTests/Runtime/Resources/Fixtures/and loaded at test time viaResources.LoadAll<TextAsset>.Dispatch audit findings
Six dispatch cases were silently falling through to the generic
OnMatchEvent/OnWorldEventbuckets, plussession.heartbeathad no surfaced event. Added explicit handlers and dedicated events:match.finishedOnMatchFinishedmatch.matchmaker_expiredOnMatchmakerExpiredmatch.matchmaker_failedOnMatchmakerFailedworld.finishedOnWorldFinishedworld.listOnWorldListworld.phase_changedOnWorldPhaseChangedsession.heartbeatOnHeartbeatDecision:
matchmaker.matchedKept as a fall-through alias to
OnMatchmakerMatchedwith a// TODO deprecatenote (server only ever emitsmatch.matched). Justification: someone got bitten by drift before and added it defensively; consumers may have wired up to it. Removing without a deprecation cycle is breaking. A dedicated test (MatchmakerMatchedAliasesMatchMatched) pins the alias so it is removed deliberately, not by accident.Test design
[Test]per fixture via[TestCaseSource](32/32 fixtures dispatched)Expectedmapping; everyExpectedentry has a fixture (catches stale entries on either side)matchmaker.matchedaliasHandleMessagemadeinternaland a parameterless test-only constructor added; visibility wired viaRuntime/AssemblyInfo.cs->[InternalsVisibleTo("Asobi.Tests")]. The test does NOT depend onMonoBehaviourand uses[Test](not[UnityTest]), so it runs in EditMode-style isolation inside the existing PlayMode test asmdef.CI status
CI will not pass on this PR until
UNITY_LICENSE/UNITY_EMAIL/UNITY_PASSWORDsecrets are added (#11). The dispatch test is correctly wired into the existing.github/workflows/smoke.ymlworkflow (it picks up everything underTests/Runtimeautomatically, andtestMode: playmodecovers[Test]attributes in the runtime-test asmdef). It will run as soon as secrets are present.Note: the pre-existing
SmokeTest.cshas compile errors (it accesses.match_id/.playersonstringevent payloads, callsSendMatchInput/Disconnectwhich do not exist) that predate this PR. They will surface once CI compiles tests; they are out of scope here per the "no SDK structural refactor" constraint and warrant a separate fix.Test plan
DispatchTests.DispatchesFixtureToExpectedEventparameterized cases all pass (32 cases)EveryFixtureHasExpectedMappingandEveryExpectedHasFixturepassMatchmakerMatchedAliasesMatchMatchedpasses