diff --git a/tests/helpers.nim b/tests/helpers.nim index 429a30a7..cff99e60 100644 --- a/tests/helpers.nim +++ b/tests/helpers.nim @@ -4,6 +4,8 @@ import helpers/templeveldb import std/times import std/sequtils, chronos +import ./asynctest + export multisetup, trackers, templeveldb ### taken from libp2p errorhelpers.nim @@ -36,13 +38,7 @@ proc allFuturesThrowing*[T, E]( # https://github.com/nim-lang/Nim/issues/23432 ): Future[void] = allFuturesThrowing(futs.mapIt(FutureBase(it))) -template eventuallySafe*(expression: untyped, timeout=5000, pollInterval=1000)): bool = - proc eventuallySafe(): Future[bool] {.async.} = - let endTime = getTime() + initDuration(milliseconds = timeout) - while not expression: - if endTime < getTime(): - return false - await sleepAsync(pollInterval) - return true - - await eventuallySafe() +template eventuallySafe*( + expression: untyped, timeout = 5000, pollInterval = 1000 +): bool = + eventually(expression, timeout, pollInterval) diff --git a/vendor/asynctest b/vendor/asynctest index 73c08f77..32df0f19 160000 --- a/vendor/asynctest +++ b/vendor/asynctest @@ -1 +1 @@ -Subproject commit 73c08f77afc5cc2a5628d00f915b97bf72f70c9b +Subproject commit 32df0f19d6e0e6f84c762cf8de7361ddb419f4ba