mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-23 19:59:32 +00:00
Fix mock clock
This commit is contained in:
parent
d6d9ce7d84
commit
34976c3c58
@ -33,11 +33,16 @@ proc advance*(clock: MockClock, seconds: int64) =
|
|||||||
method now*(clock: MockClock): SecondsSince1970 =
|
method now*(clock: MockClock): SecondsSince1970 =
|
||||||
clock.time
|
clock.time
|
||||||
|
|
||||||
method waitUntil*(clock: MockClock, time: SecondsSince1970) {.async.} =
|
method waitUntil*(
|
||||||
if time > clock.now():
|
clock: MockClock, time: SecondsSince1970
|
||||||
let future = newFuture[void]()
|
) {.async: (raises: [CancelledError]).} =
|
||||||
clock.waiting.add(Waiting(until: time, future: future))
|
try:
|
||||||
await future
|
if time > clock.now():
|
||||||
|
let future = newFuture[void]()
|
||||||
|
clock.waiting.add(Waiting(until: time, future: future))
|
||||||
|
await future
|
||||||
|
except Exception as e:
|
||||||
|
discard
|
||||||
|
|
||||||
proc isWaiting*(clock: MockClock): bool =
|
proc isWaiting*(clock: MockClock): bool =
|
||||||
clock.waiting.len > 0
|
clock.waiting.len > 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user