Ensure that `reverts` works with functions with a return type

This commit is contained in:
Mark Spanbroek 2022-09-20 13:37:53 +02:00 committed by markspanbroek
parent c5a40e5f9d
commit a62ea4fb8f
2 changed files with 7 additions and 2 deletions

View File

@ -23,7 +23,7 @@ proc reverts*[T](call: Future[T]): Future[bool] {.async.} =
when T is void:
await call
else:
discard await call # TODO test this
discard await call
return false
except ProviderError:
return true
@ -33,7 +33,7 @@ proc reverts*[T](call: Future[T], reason: string): Future[bool] {.async.} =
when T is void:
await call
else:
discard await call # TODO test this
discard await call
return false
except ProviderError as error:
return reason == error.revertReason

View File

@ -60,6 +60,11 @@ suite "Testing helpers":
check await call().reverts(nonStdMsg)
test "works with functions that return a value":
proc call(): Future[int] {.async.} = return 42
check not await call().reverts()
check not await call().reverts("some reason")
type
TestHelpers* = ref object of Contract