Commit 3407188
committed
test(core): make wait-queue's re-arm test prove the mechanism, not just the timing (H5)
The test titled "re-arms only the time actually remaining on a
re-enqueue before the deadline" asserted only on waiter.state at
various clock ticks and when its promise finally rejected -- every one
of those observations comes out identical whether #armTimeout actually
cancels the original timer and starts a fresh one for the recomputed
remainder, or simply leaves the still-live original timer alone. Both
hit the same fixed deadlineAt.
Retitled it and added clock.setTimer/cancel spies asserting on the
mechanism directly: exactly one timer is armed across the whole
queued -> processing -> queued cycle, never two. Documented in
#armTimeout's own comment why that is the only thing that can happen:
its `waiter.timer !== undefined` guard means a genuine partial-value
recompute-and-re-arm is unreachable through this class's public API --
every later call either finds the original timer still live (early
return, left untouched) or already past its deadline (enqueue's own
upfront check rejects before #armTimeout runs again).
Verified by mutating #armTimeout to unconditionally cancel and re-arm
on every call: the retitled test then fails with a named assertion
(setTimer called 2 times, expected 1), proving it can actually tell
the two mechanisms apart. Re-ran the worker's own lease-acquisition
suite, the gateway boundary/fleet-coordinator suites, and the full
unit suite (1775 passed) since this is shared core on the worker's
lease path.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MA98m7ua7qvDFZjxFaww6Z1 parent 78ebae1 commit 3407188
2 files changed
Lines changed: 45 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
155 | 167 | | |
156 | 168 | | |
| 169 | + | |
| 170 | + | |
157 | 171 | | |
158 | 172 | | |
| 173 | + | |
159 | 174 | | |
160 | 175 | | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
164 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
165 | 187 | | |
166 | 188 | | |
167 | 189 | | |
| |||
170 | 192 | | |
171 | 193 | | |
172 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
173 | 198 | | |
174 | 199 | | |
175 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
321 | 340 | | |
322 | 341 | | |
323 | 342 | | |
| |||
0 commit comments