Skip to content

Commit

Permalink
fix(filler): Auto-fill pre
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed Jun 4, 2024
1 parent 6fb9305 commit 01e776f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ethereum_test_tools/spec/eof/eof_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
from ethereum_test_forks import Fork
from evm_transition_tool import FixtureFormats, TransitionTool

from ...common import Account, Address, Alloc, Environment, Transaction
from ...common import Account, Alloc, Environment, Transaction
from ...common.base_types import Bytes
from ...common.constants import TestAddress
from ...eof.v1 import Container
from ...exceptions import EOFException, EvmoneExceptionMapper
from ..base.base_test import BaseFixture, BaseTest
Expand Down Expand Up @@ -267,8 +266,10 @@ class EOFStateTest(EOFTest):

tx_gas_limit: int = 10_000_000
tx_data: Bytes = Bytes(b"")
tx_sender_funding_amount: int = 1_000_000_000_000_000_000_000
env: Environment = Field(default_factory=Environment)
container_post: Account = Field(default_factory=Account)
pre: Alloc | None = None

supported_fixture_formats: ClassVar[List[FixtureFormats]] = [
FixtureFormats.EOF_TEST,
Expand All @@ -288,22 +289,21 @@ def generate_state_test(self) -> StateTest:
"""
Generate the StateTest filler.
"""
pre = Alloc()
container_address = Address(0x100)
pre[container_address] = Account(code=self.data, nonce=1)
pre[TestAddress] = Account(balance=1_000_000_000_000_000_000_000, nonce=0)
assert self.pre is not None, "pre must be set to generate a StateTest."
container_address = self.pre.deploy_contract(code=self.data)
sender = self.pre.fund_sender(amount=self.tx_sender_funding_amount)
tx = Transaction(
nonce=0,
to=container_address,
gas_limit=self.tx_gas_limit,
gas_price=10,
protected=False,
data=self.tx_data,
sender=sender,
)
post = Alloc()
post[container_address] = self.container_post
return StateTest(
pre=pre,
pre=self.pre,
tx=tx,
env=self.env,
post=post,
Expand Down
2 changes: 2 additions & 0 deletions src/pytest_plugins/test_filler/test_filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ def base_test_parametrizer_func(
class BaseTestWrapper(cls):
def __init__(self, *args, **kwargs):
kwargs["t8n_dump_dir"] = dump_dir_parameter_level
if "pre" not in kwargs:
kwargs["pre"] = request.getfixturevalue("pre")
super(BaseTestWrapper, self).__init__(*args, **kwargs)
fixture = self.generate(
t8n=t8n,
Expand Down

0 comments on commit 01e776f

Please sign in to comment.