Skip to content

Commit

Permalink
fix: tests and isort install [APE-1363] (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Sep 1, 2023
1 parent d528691 commit b477aee
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"types-setuptools", # Needed due to mypy typeshed
"types-PyYAML", # Needed due to mypy typeshed
"flake8>=6.0.1,<7", # Style linter
"isort>=<5.10.1,<6", # Import sorting linter
"isort>=5.10.1,<6", # Import sorting linter
"mdformat>=0.7.17", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates
Expand Down
6 changes: 0 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@ def error_contract(owner, error_contract_container):
return owner.deploy(error_contract_container)


@pytest.fixture
def reverts_contract(owner):
path = LOCAL_CONTRACTS_PATH / "reverts_contract.json"
return owner.deploy(ContractContainer(ContractType.parse_file(path)))


@pytest.fixture(scope="session")
def sender(accounts):
return accounts[0]
Expand Down
2 changes: 1 addition & 1 deletion tests/data/contracts/ethereum/local/contract_a.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/data/contracts/ethereum/local/contract_b.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/data/contracts/ethereum/local/contract_c.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tests/data/contracts/ethereum/local/reverts_contract.json

This file was deleted.

40 changes: 31 additions & 9 deletions tests/expected_traces.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,51 @@
LOCAL_TRACE = r"""
Call trace for '0x([A-Fa-f0-9]{64})'
tx\.origin=0x[a-fA-F0-9]{40}
ContractA\.methodWithoutArguments\(\) -> 0x00..5174 \[\d+ gas\]
├── SYMBOL\.methodB1\(lolol="ice-cream", dynamo=36\) \[\d+ gas\]
ContractA\.methodWithoutArguments\(\) -> 0x00\.\.5174 \[\d+ gas\]
├── SYMBOL\.supercluster\(x=234444\) -> \[
│ \[23523523235235, 11111111111, 234444\],
│ \[
│ 345345347789999991,
│ 99999998888882,
│ 345457847457457458457457457
│ \],
│ \[234444, 92222229999998888882, 3454\],
│ \[
│ 111145345347789999991,
│ 333399998888882,
│ 234545457847457457458457457457
│ \]
│ \] \[\d+ gas\]
├── SYMBOL\.methodB1\(lolol="ice-cream", dynamo=345457847457457458457457457\) \[\d+ gas\]
│ ├── ContractC\.getSomeList\(\) -> \[
│ │ 3425311345134513461345134534531452345,
│ │ 111344445534535353,
│ │ 993453434534534534534977788884443333
│ │ \] \[\d+ gas\]
│ └── ContractC\.methodC1\(windows95="simpler", jamaica=36, cardinal=ContractA\) \[\d+ gas\]
├── SYMBOL\.callMe\(blue=tx.origin\) -> tx\.origin \[\d+ gas\]
├── SYMBOL\.methodB2\(trombone=tx.origin\) \[\d+ gas\]
│ ├── ContractC\.paperwork\(ContractA\) -> \(os="simpler", country=36, wings=ContractA\) \[\d+ gas\]
│ └── ContractC\.methodC1\(
│ windows95="simpler",
│ jamaica=345457847457457458457457457,
│ cardinal=ContractA
│ \) \[\d+ gas\]
├── SYMBOL\.callMe\(blue=tx\.origin\) -> tx\.origin \[\d+ gas\]
├── SYMBOL\.methodB2\(trombone=tx\.origin\) \[\d+ gas\]
│ ├── ContractC\.paperwork\(ContractA\) -> \(
│ │ os="simpler",
│ │ country=345457847457457458457457457,
│ │ wings=ContractA
│ │ \) \[\d+ gas\]
│ ├── ContractC\.methodC1\(windows95="simpler", jamaica=0, cardinal=ContractC\) \[\d+ gas\]
│ ├── ContractC\.methodC2\(\) \[\d+ gas\]
│ └── ContractC\.methodC2\(\) \[\d+ gas\]
├── ContractC\.addressToValue\(tx\.origin\) -> 0 \[\d+ gas\]
├── SYMBOL\.bandPractice\(tx\.origin\) -> 0 \[\d+ gas\]
├── ContractC\.addressToValue\(tx.origin\) -> 0 \[\d+ gas\]
├── SYMBOL\.bandPractice\(tx.origin\) -> 0 \[\d+ gas\]
├── SYMBOL\.methodB1\(lolol="lemondrop", dynamo=0\) \[\d+ gas\]
│ ├── ContractC\.getSomeList\(\) -> \[
│ │ 3425311345134513461345134534531452345,
│ │ 111344445534535353,
│ │ 993453434534534534534977788884443333
│ │ \] \[\d+ gas\]
│ └── ContractC.methodC1\(windows95="simpler", jamaica=0, cardinal=ContractA\) \[\d+ gas\]
│ └── ContractC\.methodC1\(windows95="simpler", jamaica=0, cardinal=ContractA\) \[\d+ gas\]
└── SYMBOL\.methodB1\(lolol="snitches_get_stiches", dynamo=111\) \[\d+ gas\]
├── ContractC\.getSomeList\(\) -> \[
│ 3425311345134513461345134534531452345,
Expand Down
14 changes: 0 additions & 14 deletions tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
from ape.api.accounts import ImpersonatedAccount
from ape.exceptions import ContractLogicError
from ape.pytest.contextmanagers import RevertsContextManager as reverts
from ape.types import CallTreeNode, TraceFrame
from eth_utils import to_int
from evm_trace import CallType
Expand Down Expand Up @@ -152,19 +151,6 @@ def test_revert(sender, contract_instance):
contract_instance.setNumber(6, sender=sender)


def test_revert_dev_string_check(sender, reverts_contract):
with reverts(dev_message="dev: one"):
reverts_contract.revertStrings(1, sender=sender)

with reverts(dev_message="dev: error"):
reverts_contract.revertStrings(2, sender=sender)


def test_revert_dev_string_check_call(sender, reverts_contract):
with reverts(dev_message="dev: one"):
reverts_contract.revertStringsCall(1)


def test_contract_revert_no_message(owner, contract_instance):
# The Contract raises empty revert when setting number to 5.
with pytest.raises(ContractLogicError, match="Transaction failed."):
Expand Down

0 comments on commit b477aee

Please sign in to comment.