From fd1f539116ada24950a3afd9ac8f4572157724f1 Mon Sep 17 00:00:00 2001 From: 0xPhaze <103113487+0xPhaze@users.noreply.github.com> Date: Wed, 22 Feb 2023 10:26:19 +0100 Subject: [PATCH 1/3] feat: make `fail()` virtual Making `fail()` virtual allows us to easily plug in other frameworks. This can be useful if we want to change the behavior for an `assert(False)` statement, which would allow us to easily adapt a given test-setup for use with Echidna or the SMTChecker for formal verification. --- src/test.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test.sol b/src/test.sol index 38c5188..de504d3 100644 --- a/src/test.sol +++ b/src/test.sol @@ -62,7 +62,7 @@ contract DSTest { } } - function fail() internal { + function fail() internal virtual { if (hasHEVMContext()) { (bool status, ) = HEVM_ADDRESS.call( abi.encodePacked( From bf935e8bf81571835997f46c23e128c589adc7b7 Mon Sep 17 00:00:00 2001 From: 0xphaze <0xphaze@gmail.com> Date: Fri, 24 Feb 2023 01:54:01 +0100 Subject: [PATCH 2/3] add test case --- src/test.t.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/test.t.sol b/src/test.t.sol index 0313d16..19b7961 100644 --- a/src/test.t.sol +++ b/src/test.t.sol @@ -303,4 +303,10 @@ contract DemoTest is DSTest { function testFailAssertLeDecimalIntWithMsg() public { assertLeDecimal(-1, -2, 18, "msg"); } + + // --- fail override --- + + function fail() internal override { + super.fail(); + } } From c092d670639d748244de31d9bcbfc82333544bf4 Mon Sep 17 00:00:00 2001 From: dxo <6689924+d-xo@users.noreply.github.com> Date: Fri, 24 Feb 2023 08:01:38 +0100 Subject: [PATCH 3/3] Update src/test.t.sol --- src/test.t.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test.t.sol b/src/test.t.sol index 19b7961..996f52f 100644 --- a/src/test.t.sol +++ b/src/test.t.sol @@ -306,6 +306,7 @@ contract DemoTest is DSTest { // --- fail override --- + // ensure that fail can be overridden function fail() internal override { super.fail(); }