2021-11-04 06:38:46 +00:00
|
|
|
import
|
|
|
|
chronos,
|
2021-12-11 18:12:55 +00:00
|
|
|
../../eth/keys
|
2021-11-04 06:38:46 +00:00
|
|
|
|
|
|
|
type AssertionCallback = proc(): bool {.gcsafe, raises: [Defect].}
|
|
|
|
|
|
|
|
proc generateByteArray*(rng: var BrHmacDrbgContext, length: int): seq[byte] =
|
|
|
|
var bytes = newSeq[byte](length)
|
|
|
|
brHmacDrbgGenerate(rng, bytes)
|
|
|
|
return bytes
|
|
|
|
|
|
|
|
proc waitUntil*(f: AssertionCallback): Future[void] {.async.} =
|
|
|
|
while true:
|
|
|
|
let res = f()
|
|
|
|
if res:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
await sleepAsync(milliseconds(50))
|