From a62ea4fb8f94b2e5e35131c0ec799f02ea77aa91 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 20 Sep 2022 13:37:53 +0200 Subject: [PATCH] Ensure that `reverts` works with functions with a return type --- ethers/testing.nim | 4 ++-- testmodule/testTesting.nim | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ethers/testing.nim b/ethers/testing.nim index ea2cfcb..f082ea2 100644 --- a/ethers/testing.nim +++ b/ethers/testing.nim @@ -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 diff --git a/testmodule/testTesting.nim b/testmodule/testTesting.nim index e88dda9..8c2f35f 100644 --- a/testmodule/testTesting.nim +++ b/testmodule/testTesting.nim @@ -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