mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 14:03:10 +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 =
|
||||
clock.time
|
||||
|
||||
method waitUntil*(clock: MockClock, time: SecondsSince1970) {.async.} =
|
||||
if time > clock.now():
|
||||
let future = newFuture[void]()
|
||||
clock.waiting.add(Waiting(until: time, future: future))
|
||||
await future
|
||||
method waitUntil*(
|
||||
clock: MockClock, time: SecondsSince1970
|
||||
) {.async: (raises: [CancelledError]).} =
|
||||
try:
|
||||
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 =
|
||||
clock.waiting.len > 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user