mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-01-24 19:59:53 +00:00
fix test
This commit is contained in:
parent
661d2cea3e
commit
188b119d2e
@ -33,8 +33,8 @@ proc anyCompleted*[T](futs: seq[Future[T]]): Future[Future[T]] {.async.} =
|
||||
let index = requests.find(raceFut)
|
||||
requests.del(index)
|
||||
|
||||
proc raceCancel*[T](
|
||||
futs: seq[Future[T]]
|
||||
proc raceCancel*(
|
||||
futs: seq[Future | InternalRaisesFuture]
|
||||
): Future[void] {.async: (raises: [ValueError, CancelledError]).} =
|
||||
try:
|
||||
discard await race(futs)
|
||||
|
@ -48,5 +48,10 @@ suite "Utils Future":
|
||||
|
||||
asyncTest "raceCancel with AsyncEvent":
|
||||
let asyncEvent = newAsyncEvent()
|
||||
let fut1 = asyncEvent.wait()
|
||||
let fut2 = newAsyncEvent().wait()
|
||||
asyncEvent.fire()
|
||||
await raceCancel(@[fut1, fut2])
|
||||
|
||||
await raceCancel(@[asyncEvent.wait()])
|
||||
check fut1.finished
|
||||
check fut2.cancelled
|
||||
|
Loading…
x
Reference in New Issue
Block a user