forked from apple/swift-nio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNIOAsyncWriterTests.swift
More file actions
728 lines (554 loc) · 23.1 KB
/
Copy pathNIOAsyncWriterTests.swift
File metadata and controls
728 lines (554 loc) · 23.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2022 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import DequeModule
import NIOConcurrencyHelpers
import NIOTestUtils
import XCTest
@testable import NIOCore
private struct SomeError: Error, Hashable {}
private final class MockAsyncWriterDelegate: NIOAsyncWriterSinkDelegate, @unchecked Sendable {
typealias Element = String
var _didYieldCallCount = NIOLockedValueBox(0)
var didYieldCallCount: Int {
self._didYieldCallCount.withLockedValue { $0 }
}
var didYieldHandler: ((Deque<String>) -> Void)?
func didYield(contentsOf sequence: Deque<String>) {
self._didYieldCallCount.withLockedValue { $0 += 1 }
if let didYieldHandler = self.didYieldHandler {
didYieldHandler(sequence)
}
}
var _didSuspendCallCount = NIOLockedValueBox(0)
var didSuspendCallCount: Int {
self._didSuspendCallCount.withLockedValue { $0 }
}
var didSuspendHandler: (() -> Void)?
func didSuspend() {
self._didSuspendCallCount.withLockedValue { $0 += 1 }
if let didSuspendHandler = self.didSuspendHandler {
didSuspendHandler()
}
}
var _didTerminateCallCount = NIOLockedValueBox(0)
var didTerminateCallCount: Int {
self._didTerminateCallCount.withLockedValue { $0 }
}
var didTerminateHandler: ((Error?) -> Void)?
func didTerminate(error: Error?) {
self._didTerminateCallCount.withLockedValue { $0 += 1 }
if let didTerminateHandler = self.didTerminateHandler {
didTerminateHandler(error)
}
}
}
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
final class NIOAsyncWriterTests: XCTestCase {
private var writer: NIOAsyncWriter<String, MockAsyncWriterDelegate>!
private var sink: NIOAsyncWriter<String, MockAsyncWriterDelegate>.Sink!
private var delegate: MockAsyncWriterDelegate!
override func setUp() {
super.setUp()
let delegate = MockAsyncWriterDelegate()
self.delegate = delegate
let newWriter = NIOAsyncWriter.makeWriter(
elementType: String.self,
isWritable: true,
finishOnDeinit: false,
delegate: self.delegate
)
self.writer = newWriter.writer
self.sink = newWriter.sink
self.sink._storage._setDidSuspend { delegate.didSuspend() }
}
override func tearDown() {
if let writer = self.writer {
writer.finish()
}
if let sink = self.sink {
sink.finish()
}
self.delegate = nil
self.writer = nil
self.sink = nil
super.tearDown()
}
func assert(
suspendCallCount: Int,
yieldCallCount: Int,
terminateCallCount: Int,
file: StaticString = #filePath,
line: UInt = #line
) {
XCTAssertEqual(
self.delegate.didSuspendCallCount,
suspendCallCount,
"Unexpeced suspends",
file: file,
line: line
)
XCTAssertEqual(self.delegate.didYieldCallCount, yieldCallCount, "Unexpected yields", file: file, line: line)
XCTAssertEqual(
self.delegate.didTerminateCallCount,
terminateCallCount,
"Unexpected terminates",
file: file,
line: line
)
}
func testMultipleConcurrentWrites() async throws {
var elements = 0
self.delegate.didYieldHandler = { elements += $0.count }
let task1 = Task { [writer] in
for i in 0...9 {
try await writer!.yield("message\(i)")
}
}
let task2 = Task { [writer] in
for i in 10...19 {
try await writer!.yield("message\(i)")
}
}
let task3 = Task { [writer] in
for i in 20...29 {
try await writer!.yield("message\(i)")
}
}
try await task1.value
try await task2.value
try await task3.value
XCTAssertEqual(elements, 30)
}
func testMultipleConcurrentBatchWrites() async throws {
var elements = 0
self.delegate.didYieldHandler = { elements += $0.count }
let task1 = Task { [writer] in
for i in 0...9 {
try await writer!.yield(contentsOf: ["message\(i).1", "message\(i).2"])
}
}
let task2 = Task { [writer] in
for i in 10...19 {
try await writer!.yield(contentsOf: ["message\(i).1", "message\(i).2"])
}
}
let task3 = Task { [writer] in
for i in 20...29 {
try await writer!.yield(contentsOf: ["message\(i).1", "message\(i).2"])
}
}
try await task1.value
try await task2.value
try await task3.value
XCTAssertEqual(elements, 60)
}
// MARK: - WriterDeinitialized
func testWriterDeinitialized_whenInitial() async throws {
var newWriter: NIOAsyncWriter<String, MockAsyncWriterDelegate>.NewWriter? = NIOAsyncWriter.makeWriter(
elementType: String.self,
isWritable: true,
finishOnDeinit: true,
delegate: self.delegate
)
let sink = newWriter!.sink
var writer: NIOAsyncWriter<String, MockAsyncWriterDelegate>? = newWriter!.writer
newWriter = nil
writer = nil
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
XCTAssertNil(writer)
sink.finish()
}
func testWriterDeinitialized_whenStreaming() async throws {
var newWriter: NIOAsyncWriter<String, MockAsyncWriterDelegate>.NewWriter? = NIOAsyncWriter.makeWriter(
elementType: String.self,
isWritable: true,
finishOnDeinit: true,
delegate: self.delegate
)
let sink = newWriter!.sink
var writer: NIOAsyncWriter<String, MockAsyncWriterDelegate>? = newWriter!.writer
newWriter = nil
try await writer!.yield("message1")
writer = nil
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 1)
XCTAssertNil(writer)
sink.finish()
}
func testWriterDeinitialized_whenWriterFinished() async throws {
try await writer.yield("message1")
self.writer.finish()
self.writer = nil
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 1)
}
func testWriterDeinitialized_whenFinished() async throws {
self.sink.finish()
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
self.writer = nil
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
}
// MARK: - ToggleWritability
func testSetWritability_whenInitial() async throws {
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
Task { [writer] in
try await writer!.yield("message1")
}
await fulfillment(of: [suspended], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 0, terminateCallCount: 0)
}
func testSetWritability_whenStreaming_andBecomingUnwritable() async throws {
try await self.writer.yield("message1")
XCTAssertEqual(self.delegate.didYieldCallCount, 1)
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
Task { [writer] in
try await writer!.yield("message2")
}
await fulfillment(of: [suspended], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 0)
}
func testSetWritability_whenStreaming_andBecomingWritable() async throws {
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
let resumed = expectation(description: "yield completed")
Task { [writer] in
try await writer!.yield("message2")
resumed.fulfill()
}
await fulfillment(of: [suspended], timeout: 1)
self.sink.setWritability(to: true)
await fulfillment(of: [resumed], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 0)
}
func testSetWritability_whenStreaming_andSettingSameWritability() async throws {
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
Task { [writer] in
try await writer!.yield("message1")
}
await fulfillment(of: [suspended], timeout: 1)
// Setting the writability to the same state again shouldn't change anything
self.sink.setWritability(to: false)
self.assert(suspendCallCount: 1, yieldCallCount: 0, terminateCallCount: 0)
}
func testSetWritability_whenWriterFinished() async throws {
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
let resumed = expectation(description: "yield completed")
Task { [writer] in
try await writer!.yield("message1")
resumed.fulfill()
}
await fulfillment(of: [suspended], timeout: 1)
self.writer.finish()
self.assert(suspendCallCount: 1, yieldCallCount: 0, terminateCallCount: 0)
self.sink.setWritability(to: true)
await fulfillment(of: [resumed], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 1)
}
func testSetWritability_whenFinished() async throws {
self.sink.finish()
self.sink.setWritability(to: false)
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
}
// MARK: - Yield
func testYield_whenInitial_andWritable() async throws {
try await self.writer.yield("message1")
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
}
func testYield_whenInitial_andNotWritable() async throws {
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
Task { [writer] in
try await writer!.yield("message2")
}
await fulfillment(of: [suspended], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 0, terminateCallCount: 0)
}
func testYield_whenStreaming_andWritable() async throws {
try await self.writer.yield("message1")
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
try await self.writer.yield("message2")
self.assert(suspendCallCount: 0, yieldCallCount: 2, terminateCallCount: 0)
}
func testYield_whenStreaming_andNotWritable() async throws {
try await self.writer.yield("message1")
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
Task { [writer] in
try await writer!.yield("message2")
}
await fulfillment(of: [suspended], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 0)
}
func testYield_whenStreaming_andYieldCancelled() async throws {
try await self.writer.yield("message1")
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
let cancelled = expectation(description: "task cancelled")
let task = Task { [writer] in
await XCTWaiter().fulfillment(of: [cancelled], timeout: 1)
try await writer!.yield("message2")
}
task.cancel()
cancelled.fulfill()
await XCTAssertThrowsError(try await task.value) { error in
XCTAssertTrue(error is CancellationError)
}
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
}
func testYield_whenWriterFinished() async throws {
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
Task { [writer] in
try await writer!.yield("message1")
}
await fulfillment(of: [suspended], timeout: 1)
self.writer.finish()
await XCTAssertThrowsError(try await self.writer.yield("message1")) { error in
XCTAssertEqual(error as? NIOAsyncWriterError, .alreadyFinished())
}
self.assert(suspendCallCount: 1, yieldCallCount: 0, terminateCallCount: 0)
}
func testYield_whenFinished() async throws {
self.sink.finish()
await XCTAssertThrowsError(try await self.writer.yield("message1")) { error in
XCTAssertEqual(error as? NIOAsyncWriterError, .alreadyFinished())
}
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
}
func testYield_whenFinishedError() async throws {
self.sink.finish(error: SomeError())
await XCTAssertThrowsError(try await self.writer.yield("message1")) { error in
XCTAssertTrue(error is SomeError)
}
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
}
// MARK: - Cancel
func testCancel_whenInitial() async throws {
let cancelled = expectation(description: "task cancelled")
let task = Task { [writer] in
await XCTWaiter().fulfillment(of: [cancelled], timeout: 1)
try await writer!.yield("message1")
}
task.cancel()
cancelled.fulfill()
await XCTAssertThrowsError(try await task.value) { error in
XCTAssertTrue(error is CancellationError)
}
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
}
func testCancel_whenStreaming_andCancelBeforeYield() async throws {
try await self.writer.yield("message1")
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
let cancelled = expectation(description: "task cancelled")
let task = Task { [writer] in
await XCTWaiter().fulfillment(of: [cancelled], timeout: 1)
try await writer!.yield("message2")
}
task.cancel()
cancelled.fulfill()
await XCTAssertThrowsError(try await task.value) { error in
XCTAssertTrue(error is CancellationError)
}
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
}
func testCancel_whenStreaming_andCancelAfterSuspendedYield() async throws {
try await self.writer.yield("message1")
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
let task = Task { [writer] in
try await writer!.yield("message2")
}
await fulfillment(of: [suspended], timeout: 1)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 0)
task.cancel()
await XCTAssertThrowsError(try await task.value) { error in
XCTAssertTrue(error is CancellationError)
}
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 0)
self.sink.setWritability(to: true)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 0)
}
func testCancel_whenFinished() async throws {
self.writer.finish()
XCTAssertEqual(self.delegate.didTerminateCallCount, 1)
let cancelled = expectation(description: "task cancelled")
let task = Task { [writer] in
await XCTWaiter().fulfillment(of: [cancelled], timeout: 1)
try await writer!.yield("message1")
}
task.cancel()
cancelled.fulfill()
await XCTAssertThrowsError(try await task.value) { error in
XCTAssertEqual(error as? NIOAsyncWriterError, .alreadyFinished())
}
XCTAssertEqual(self.delegate.didYieldCallCount, 0)
}
// MARK: - Writer Finish
func testWriterFinish_whenInitial() async throws {
self.writer.finish()
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
}
func testWriterFinish_whenInitial_andFailure() async throws {
self.writer.finish(error: SomeError())
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
}
func testWriterFinish_whenStreaming() async throws {
try await self.writer!.yield("message1")
self.writer.finish()
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 1)
}
func testWriterFinish_whenStreaming_AndBufferedElements() async throws {
// We are setting up a suspended yield here to check that it gets resumed
self.sink.setWritability(to: false)
let suspended = expectation(description: "suspended on yield")
self.delegate.didSuspendHandler = {
suspended.fulfill()
}
let task = Task { [writer] in
try await writer!.yield("message1")
}
await fulfillment(of: [suspended], timeout: 1)
self.writer.finish()
self.assert(suspendCallCount: 1, yieldCallCount: 0, terminateCallCount: 0)
// We have to become writable again to unbuffer the yield
self.sink.setWritability(to: true)
await XCTAssertNoThrow(try await task.value)
self.assert(suspendCallCount: 1, yieldCallCount: 1, terminateCallCount: 1)
}
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
func testWriterFinish_AndSuspendBufferedYield() async throws {
#if compiler(>=6)
try await withThrowingTaskGroup(of: Void.self) { group in
try await withManualTaskExecutor { taskExecutor1, taskExecutor2 in
self.sink.setWritability(to: false)
self.delegate.didYieldHandler = { _ in
if self.delegate.didYieldCallCount == 1 {
// This is the yield of the first task. Run the second task until it suspends again
self.assert(suspendCallCount: 2, yieldCallCount: 1, terminateCallCount: 0)
taskExecutor2.runUntilQueueIsEmpty()
self.assert(suspendCallCount: 3, yieldCallCount: 1, terminateCallCount: 0)
}
}
group.addTask(executorPreference: taskExecutor1) { [writer] in
try await writer!.yield("message1")
}
group.addTask(executorPreference: taskExecutor2) { [writer] in
try await writer!.yield("message2")
}
// Run tasks until they are both suspended
taskExecutor1.runUntilQueueIsEmpty()
taskExecutor2.runUntilQueueIsEmpty()
self.assert(suspendCallCount: 2, yieldCallCount: 0, terminateCallCount: 0)
self.writer.finish()
// We have to become writable again to unbuffer the yields
self.sink.setWritability(to: true)
// Run the first task, which will complete its yield
// During this yield, didYieldHandler will run the second task, which will suspend again
taskExecutor1.runUntilQueueIsEmpty()
self.assert(suspendCallCount: 3, yieldCallCount: 1, terminateCallCount: 0)
// Run the second task to complete its yield
taskExecutor2.runUntilQueueIsEmpty()
self.assert(suspendCallCount: 3, yieldCallCount: 2, terminateCallCount: 1)
await XCTAssertNoThrow(try await group.next())
await XCTAssertNoThrow(try await group.next())
}
}
#endif // compiler(>=6)
}
func testWriterFinish_whenFinished() {
// This tests just checks that finishing again is a no-op
self.writer.finish()
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
self.writer.finish()
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
}
// MARK: - Sink Finish
func testSinkFinish_whenInitial() async throws {
var newWriter: NIOAsyncWriter<String, MockAsyncWriterDelegate>.NewWriter? = NIOAsyncWriter.makeWriter(
elementType: String.self,
isWritable: true,
finishOnDeinit: true,
delegate: self.delegate
)
var sink: NIOAsyncWriter<String, MockAsyncWriterDelegate>.Sink? = newWriter!.sink
let writer = newWriter!.writer
newWriter = nil
sink = nil
XCTAssertNil(sink)
XCTAssertNotNil(writer)
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 0)
}
func testSinkFinish_whenStreaming() async throws {
var newWriter: NIOAsyncWriter<String, MockAsyncWriterDelegate>.NewWriter? = NIOAsyncWriter.makeWriter(
elementType: String.self,
isWritable: true,
finishOnDeinit: true,
delegate: self.delegate
)
var sink: NIOAsyncWriter<String, MockAsyncWriterDelegate>.Sink? = newWriter!.sink
let writer = newWriter!.writer
newWriter = nil
try await writer.yield("message1")
sink = nil
XCTAssertNil(sink)
self.assert(suspendCallCount: 0, yieldCallCount: 1, terminateCallCount: 0)
}
func testSinkFinish_whenFinished() async throws {
self.writer.finish()
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
self.sink = nil
self.assert(suspendCallCount: 0, yieldCallCount: 0, terminateCallCount: 1)
}
}
#if !canImport(Darwin) && swift(<5.9.2)
extension XCTestCase {
func fulfillment(
of expectations: [XCTestExpectation],
timeout seconds: TimeInterval,
enforceOrder enforceOrderOfFulfillment: Bool = false
) async {
wait(for: expectations, timeout: seconds)
}
}
#endif