Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nested prank error message #428

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/halmos/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,15 @@ def setup(
print(f"{setup_sig} trace #{idx+1}:")
render_trace(setup_ex.context)

if not setup_ex.context.output.error:
if not (err := setup_ex.context.output.error):
setup_exs_no_error.append((setup_ex, setup_ex.path.to_smt2(args)))

else:
opcode = setup_ex.current_opcode()
if opcode not in [EVM.REVERT, EVM.INVALID]:
warn_code(
INTERNAL_ERROR,
f"Warning: {setup_sig} execution encountered an issue at {mnemonic(opcode)}: {error}",
f"in {setup_sig}, executing {mnemonic(opcode)} failed with: {err}",
)

# only render the trace if we didn't already do it
Expand Down Expand Up @@ -887,7 +887,7 @@ def run_sequential(run_args: RunArgs) -> list[TestResult]:
setup_solver,
)
except Exception as err:
error(f"Error: {setup_info.sig} failed: {type(err).__name__}: {err}")
error(f"{setup_info.sig} failed: {type(err).__name__}: {err}")
if args.debug:
traceback.print_exc()
# reset any remaining solver states from the default context
Expand Down Expand Up @@ -1500,7 +1500,7 @@ def on_signal(signum, frame):

if total_found == 0:
error(
"Error: No tests with"
"No tests with"
+ f" --match-contract '{contract_regex(args)}'"
+ f" --match-test '{test_regex(args)}'"
)
Expand Down
16 changes: 12 additions & 4 deletions src/halmos/cheatcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ def handle(sevm, ex, arg: ByteVec, stack, step_id) -> ByteVec | None:
sender = uint160(arg.get_word(4))
result = ex.context.prank.prank(sender)
if not result:
raise HalmosException("You have an active prank already.")
raise HalmosException(
"can not call vm.prank(address) with an active prank"
)
return ret

# vm.prank(address sender, address origin)
Expand All @@ -611,15 +613,19 @@ def handle(sevm, ex, arg: ByteVec, stack, step_id) -> ByteVec | None:
origin = uint160(arg.get_word(36))
result = ex.context.prank.prank(sender, origin)
if not result:
raise HalmosException("You have an active prank already.")
raise HalmosException(
"can not call vm.prank(address, address) with an active prank"
)
return ret

# vm.startPrank(address)
elif funsig == hevm_cheat_code.start_prank_sig:
address = uint160(arg.get_word(4))
result = ex.context.prank.startPrank(address)
if not result:
raise HalmosException("You have an active prank already.")
raise HalmosException(
"can not call vm.startPrank(address) with an active prank"
)
return ret

# vm.startPrank(address sender, address origin)
Expand All @@ -628,7 +634,9 @@ def handle(sevm, ex, arg: ByteVec, stack, step_id) -> ByteVec | None:
origin = uint160(arg.get_word(36))
result = ex.context.prank.startPrank(sender, origin)
if not result:
raise HalmosException("You have an active prank already.")
raise HalmosException(
"can not call vm.startPrank(address, address) with an active prank"
)
return ret

# vm.stopPrank()
Expand Down
2 changes: 1 addition & 1 deletion src/halmos/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

logging.basicConfig(
format="%(message)s",
handlers=[RichHandler(level=logging.NOTSET, show_time=False)],
handlers=[RichHandler(level=logging.NOTSET, show_time=False, show_path=False)],
)

logger = logging.getLogger("halmos")
Expand Down
Loading