test: assert the result of timed SemaphoreSlim.WaitAsync in GatewaySessionTests (mxaccessgw#221)
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:
@@ -267,7 +267,7 @@ public sealed class GatewaySessionTests
|
|||||||
{
|
{
|
||||||
// All threads wait at the gate so they start as simultaneously
|
// All threads wait at the gate so they start as simultaneously
|
||||||
// as the scheduler allows, maximising the race window.
|
// 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();
|
lease.Dispose();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -423,7 +423,7 @@ public sealed class GatewaySessionTests
|
|||||||
int index = t;
|
int index = t;
|
||||||
tasks[index] = Task.Run(async () =>
|
tasks[index] = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await gate.WaitAsync(testTimeout);
|
Assert.True(await gate.WaitAsync(testTimeout), "Timed out at the start gate.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IEventSubscriberLease lease = session.AttachEventSubscriber(maxSubscribers: Cap);
|
IEventSubscriberLease lease = session.AttachEventSubscriber(maxSubscribers: Cap);
|
||||||
|
|||||||
Reference in New Issue
Block a user