Ensure that `reverts` works with functions with a return type
This commit is contained in:
parent
c5a40e5f9d
commit
a62ea4fb8f
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue