From 8b5b151632ddc935a995d3e90126d11cc40b7a17 Mon Sep 17 00:00:00 2001 From: karmacoma Date: Fri, 20 Oct 2023 15:44:04 -0700 Subject: [PATCH] add test for console.log with undecode string --- src/halmos/console.py | 2 +- tests/expected/all.json | 9 +++++++++ tests/regression/test/Console.t.sol | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/halmos/console.py b/src/halmos/console.py index cf43bb3c..1fa0ed27 100644 --- a/src/halmos/console.py +++ b/src/halmos/console.py @@ -108,4 +108,4 @@ def handle(ex, arg: BitVec) -> None: ) except Exception as e: # we don't want to fail execution because of an issue during console.log - warn(f"console.handle: {repr(e)}") + warn(f"console.handle: {repr(e)} with arg={hexify(arg)}") diff --git a/tests/expected/all.json b/tests/expected/all.json index e1d99045..4e09cdef 100644 --- a/tests/expected/all.json +++ b/tests/expected/all.json @@ -335,6 +335,15 @@ "time": null, "num_bounded_loops": null }, + { + "name": "check_log_undecodable_string()", + "exitcode": 0, + "num_models": 0, + "models": null, + "num_paths": null, + "time": null, + "num_bounded_loops": null + }, { "name": "check_log_unsupported()", "exitcode": 0, diff --git a/tests/regression/test/Console.t.sol b/tests/regression/test/Console.t.sol index 96d6bd85..35002b78 100644 --- a/tests/regression/test/Console.t.sol +++ b/tests/regression/test/Console.t.sol @@ -70,6 +70,12 @@ contract ConsoleTest is Test { console2.log(empty); } + function check_log_undecodable_string() public view { + bytes memory badBytes = hex"ff"; + string memory bad = string(badBytes); + console2.log("this is a string that won't decode to utf-8:", bad); + } + function check_log_unsupported() public { console2._sendLogPayload(abi.encodeWithSignature("doesNotExist()")); }