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

Test EIP-2929 #689

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions tests/berlin/eip2929_state_gas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
abstract: Tests [EIP-2929: Gas cost increases for state access opcodes][0]
Test cases for [EIP-2929: Gas cost increases for state access opcodes][0].

[0]: https://eips.ethereum.org/EIPS/eip-2929
"""
55 changes: 55 additions & 0 deletions tests/berlin/eip2929_state_gas/test_call.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Test the CALL family of instructions after EIP-2929
"""

import pytest

from ethereum_test_tools import Account, Alloc, Environment
from ethereum_test_tools import Opcodes as Op
from ethereum_test_tools import StateTestFiller, Transaction

REFERENCE_SPEC_GIT_PATH = "EIPS/eip-2929.md"
REFERENCE_SPEC_VERSION = "949de3748527504fba8ef5a47cc76413fff85159"


@pytest.mark.valid_from("Berlin")
def test_call_insufficient_balance(state_test: StateTestFiller, pre: Alloc):
"""
Test a regular CALL to see if it warms the destination with insufficient
balance.
"""
env = Environment()

destination = pre.fund_eoa(1)
contract_address = pre.deploy_contract(
Op.CALL(
gas=Op.GAS,
address=destination,
value=1,
args_offset=0,
args_size=0,
ret_offset=0,
ret_size=0,
)
+ Op.SSTORE(key=1, value=Op.BALANCE(address=destination))
+ Op.SSTORE(key=2, value=Op.GAS),
balance=0,
)
sender = pre.fund_eoa(0x3000000000)

tx = Transaction(
chain_id=0x01,
to=contract_address,
value=0,
gas_limit=323328,
access_list=[],
protected=True,
sender=sender,
)

post = {
destination: Account(
balance=1,
),
}
state_test(env=env, pre=pre, post=post, tx=tx)
Loading