Skip to content

Commit

Permalink
fix: rm reverts prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Dec 31, 2024
1 parent f6d1db3 commit fa6c89b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ape_foundry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ def _handle_execution_reverted( # type: ignore[override]
else:
revert_message = revert_message or TransactionError.DEFAULT_MESSAGE

if revert_message.startswith("revert: "):
revert_message = revert_message[8:]

# Create and enrich the error
sub_err = ContractLogicError(base_err=exception, revert_message=revert_message, **kwargs)
enriched = self.compiler_manager.enrich_error(sub_err)
Expand Down
6 changes: 5 additions & 1 deletion tests/test_provider.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

import pytest
from ape import convert
from ape import convert, reverts
from ape.api import TraceAPI
from ape.api.accounts import ImpersonatedAccount
from ape.contracts import ContractContainer
Expand Down Expand Up @@ -192,6 +192,10 @@ def test_revert(sender, contract_instance):
with pytest.raises(ContractLogicError, match="!authorized"):
contract_instance.setNumber(6, sender=sender)

# Show it also works with the reverts-context-manager.
with reverts("!authorized"):
contract_instance.setNumber(55, sender=sender)


def test_contract_revert_no_message(owner, contract_instance):
# The Contract raises empty revert when setting number to 5.
Expand Down

0 comments on commit fa6c89b

Please sign in to comment.