Skip to content

Commit

Permalink
add test for console.log with undecode string
Browse files Browse the repository at this point in the history
  • Loading branch information
karmacoma-eth committed Oct 20, 2023
1 parent 0c25d1b commit 8b5b151
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/halmos/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
9 changes: 9 additions & 0 deletions tests/expected/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/regression/test/Console.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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()"));
}
Expand Down

0 comments on commit 8b5b151

Please sign in to comment.