From 71a09d6bb2bf9e02ae086669bdc8c0dc520187c4 Mon Sep 17 00:00:00 2001 From: Bayu Aldi Yansyah <bayualdiyansyah@gmail.com> Date: Fri, 24 Sep 2021 01:41:21 +0700 Subject: [PATCH 1/3] make test: Add solc:0.8.6 --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 661dac4..ef2ab07 100644 --- a/Makefile +++ b/Makefile @@ -6,9 +6,10 @@ test: -dapp --use solc:0.5.17 build -dapp --use solc:0.6.12 build -dapp --use solc:0.7.5 build + -dapp --use solc:0.8.6 build demo: - DAPP_SRC=demo dapp --use solc:0.7.5 build + DAPP_SRC=demo dapp --use solc:0.8.6 build -hevm dapp-test --verbose 3 .PHONY: test demo From 4f9fa69723f1227aa6ad23f0666c8b6d788d09ae Mon Sep 17 00:00:00 2001 From: Bayu Aldi Yansyah <bayualdiyansyah@gmail.com> Date: Fri, 24 Sep 2021 01:42:04 +0700 Subject: [PATCH 2/3] Add support for boolean --- src/test.sol | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test.sol b/src/test.sol index 96d3c15..f3fc04d 100644 --- a/src/test.sol +++ b/src/test.sol @@ -34,6 +34,7 @@ contract DSTest { event log_named_uint (string key, uint val); event log_named_bytes (string key, bytes val); event log_named_string (string key, string val); + event log_named_bool (string key, bool val); bool public IS_TEST = true; bool public failed; @@ -161,6 +162,20 @@ contract DSTest { assertEqDecimal(a, b, decimals); } } + function assertEq(bool a, bool b) internal { + if (a != b) { + emit log("Error: a == b not satisfied [bool]"); + emit log_named_bool(" Expected", b); + emit log_named_bool(" Actual", a); + fail(); + } + } + function assertEq(bool a, bool b, string memory err) internal { + if (a != b) { + emit log_named_string("Error", err); + assertEq(a, b); + } + } function assertGt(uint a, uint b) internal { if (a <= b) { From 2ba9333d7c28ea1aa9cde9e9a8e42b7d38257dd7 Mon Sep 17 00:00:00 2001 From: Bayu Aldi Yansyah <bayualdiyansyah@gmail.com> Date: Fri, 24 Sep 2021 01:43:23 +0700 Subject: [PATCH 3/3] Add assertFalse --- src/test.sol | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test.sol b/src/test.sol index f3fc04d..20abd3b 100644 --- a/src/test.sol +++ b/src/test.sol @@ -70,6 +70,20 @@ contract DSTest { } } + function assertFalse(bool condition) internal { + if (condition) { + emit log("Error: Assertion Failed"); + fail(); + } + } + + function assertFalse(bool condition, string memory err) internal { + if (condition) { + emit log_named_string("Error", err); + assertTrue(condition); + } + } + function assertEq(address a, address b) internal { if (a != b) { emit log("Error: a == b not satisfied [address]");