Skip to content

Commit bbf4601

Browse files
committed
test(devices): collapse deliberation comment in SwitchPrimingTests
1 parent 8a4480a commit bbf4601

1 file changed

Lines changed: 2 additions & 27 deletions

File tree

tests/RustPlusBot.Features.Connections.Tests/SwitchPrimingTests.cs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -114,33 +114,8 @@ public async Task Prime_RemovedSwitch_PublishesRemovedReachability_AndNoActiveSt
114114
await using var disposeProvider = provider;
115115
var serverId = await SeedServerWithActiveAndSwitchAsync(provider, entityId: 42UL);
116116

117-
// Configure the fake's reachability override so GetSmartDeviceInfoAsync returns Removed for entity 42.
118-
// This must be staged before EnsureConnectionAsync so it's in place when the prime loop runs.
119-
// FakeConnection is created inside Create(), so we stage via the source's pre-connect hook, but
120-
// DeviceReachabilityOverrides is on FakeConnection — we set it after the first Create() via
121-
// LastConnection. However, Create() fires during EnsureConnectionAsync (inside the background task),
122-
// so we can't access LastConnection before EnsureConnectionAsync completes. Instead we use
123-
// a connect-outcome hook: stage Connected so the connection is created; then wait for HasLiveSocket.
124-
//
125-
// To avoid the race, we subscribe to DeviceReachabilityChangedEvent before connecting and
126-
// set the override on the source's pending-storage approach is not available for switches.
127-
// The brief says to use DeviceReachabilityOverrides — set it before EnsureConnectionAsync
128-
// by using a custom FakeRustSocketSource subclass or by seeding it via a staging dictionary.
129-
//
130-
// The cleanest race-free approach: subscribe first, then EnsureConnectionAsync, then wait
131-
// for HasLiveSocket, then check published events — but priming fires BEFORE HasLiveSocket
132-
// check is possible via polling. We use the same approach as AlarmPrimingTests: subscribe
133-
// to the reachability event (which fires only after the new prime code), wait for it, then
134-
// assert absence of SmartDeviceTriggeredEvent{IsActive:false}.
135-
//
136-
// To stage the override before prime: add a pre-stage dictionary on FakeRustSocketSource
137-
// analogous to _pendingStorageContents (which transfers to FakeConnection at Create time).
138-
// However the brief says the fake already has DeviceReachabilityOverrides and to "use it".
139-
// Per the brief Task 4 note: "Read that fake to learn its exact API."
140-
// FakeRustSocketSource already has _pendingStorageContents transferred at Create time;
141-
// FakeConnection.DeviceReachabilityOverrides exists but has no pre-stage path in the source.
142-
// We add a minimal PendingDeviceReachabilityOverrides staging dict to FakeRustSocketSource
143-
// (transferred at Create time, like _pendingStorageContents) — documented in the report.
117+
// Stage the fake so entity 42's prime read returns Removed (mirrors how the other
118+
// *PrimingTests stage device state before EnsureConnectionAsync).
144119
source.StageDeviceReachability(42UL, DeviceReachability.Removed);
145120

146121
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));

0 commit comments

Comments
 (0)