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:
|
when T is void:
|
||||||
await call
|
await call
|
||||||
else:
|
else:
|
||||||
discard await call # TODO test this
|
discard await call
|
||||||
return false
|
return false
|
||||||
except ProviderError:
|
except ProviderError:
|
||||||
return true
|
return true
|
||||||
|
@ -33,7 +33,7 @@ proc reverts*[T](call: Future[T], reason: string): Future[bool] {.async.} =
|
||||||
when T is void:
|
when T is void:
|
||||||
await call
|
await call
|
||||||
else:
|
else:
|
||||||
discard await call # TODO test this
|
discard await call
|
||||||
return false
|
return false
|
||||||
except ProviderError as error:
|
except ProviderError as error:
|
||||||
return reason == error.revertReason
|
return reason == error.revertReason
|
||||||
|
|
|
@ -60,6 +60,11 @@ suite "Testing helpers":
|
||||||
|
|
||||||
check await call().reverts(nonStdMsg)
|
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
|
type
|
||||||
TestHelpers* = ref object of Contract
|
TestHelpers* = ref object of Contract
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue