diff --git a/src/DiffEngine.Tests/ViewerProtocolTests.cs b/src/DiffEngine.Tests/ViewerProtocolTests.cs index c581eedb..ab1f05a5 100644 --- a/src/DiffEngine.Tests/ViewerProtocolTests.cs +++ b/src/DiffEngine.Tests/ViewerProtocolTests.cs @@ -845,11 +845,24 @@ public async Task AnAbsentOwnerIsNotAnError() await Assert.That(ViewerClient.TrySend(new(ViewerVerb.List), out _, port)).IsFalse(); } + /// + /// Drains the listener at the end of a test. + /// + /// On rather than a margin of its own. Unwinding needs the accept's + /// continuation to be scheduled, and that waits on the same thread pool everything else here + /// does - so five seconds was the same bet the client timeout above had already stopped + /// making, and it lost the same way. + /// + /// + /// Still throws when it runs out, because a listener that never unwinds is a real bug and this + /// is the only place that would notice. + /// + /// static async Task Wait(Task listening) { try { - await listening.WaitAsync(TimeSpan.FromSeconds(5)); + await listening.WaitAsync(underLoad); } catch (OperationCanceledException) {