test: assert the result of timed SemaphoreSlim.WaitAsync in GatewaySessionTests (mxaccessgw#221)
ci / nightly-windev (push) Has been skipped
ci / windows-x86 (push) Successful in 1m30s
ci / java (push) Successful in 2m24s
ci / portable (push) Failing after 4m24s

The two start-gate waits in GatewaySessionTests ignored the bool from
WaitAsync(timeout), so a wait that timed out let the task run on
un-synchronised and the race test could pass without racing. Both now
Assert.True the result. Every other timed semaphore wait in the Tests
project was already checked (the #205 lease helper, the new CountSignal)
or is token-only.

Mutation check: with Release(n-1) and a 200 ms gate wait, the original
code passes (vacuous) while the fixed code fails with "Timed out at the
start gate."

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 13:09:33 -05:00
parent 82d29beafd
commit b47a168a2c
@@ -267,7 +267,7 @@ public sealed class GatewaySessionTests
{
// All threads wait at the gate so they start as simultaneously
// as the scheduler allows, maximising the race window.
await gate.WaitAsync(testTimeout);
Assert.True(await gate.WaitAsync(testTimeout), "Timed out at the start gate.");
lease.Dispose();
});
}
@@ -423,7 +423,7 @@ public sealed class GatewaySessionTests
int index = t;
tasks[index] = Task.Run(async () =>
{
await gate.WaitAsync(testTimeout);
Assert.True(await gate.WaitAsync(testTimeout), "Timed out at the start gate.");
try
{
IEventSubscriberLease lease = session.AttachEventSubscriber(maxSubscribers: Cap);