Skip to content

Commit 6d8ba90

Browse files
SamWilsnLouisTsai-Csie
authored andcommitted
Test EIP-2929
1 parent 4ba770d commit 6d8ba90

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""
2+
abstract: Tests [EIP-2929: Gas cost increases for state access opcodes][0]
3+
Test cases for [EIP-2929: Gas cost increases for state access opcodes][0].
4+
5+
[0]: https://eips.ethereum.org/EIPS/eip-2929
6+
"""
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Test the CALL family of instructions after EIP-2929
3+
"""
4+
5+
import pytest
6+
7+
from ethereum_test_tools import Account, Alloc, Environment
8+
from ethereum_test_tools import Opcodes as Op
9+
from ethereum_test_tools import StateTestFiller, Transaction
10+
11+
REFERENCE_SPEC_GIT_PATH = "EIPS/eip-2929.md"
12+
REFERENCE_SPEC_VERSION = "949de3748527504fba8ef5a47cc76413fff85159"
13+
14+
15+
@pytest.mark.valid_from("Berlin")
16+
def test_call_insufficient_balance(state_test: StateTestFiller, pre: Alloc):
17+
"""
18+
Test a regular CALL to see if it warms the destination with insufficient
19+
balance.
20+
"""
21+
env = Environment()
22+
23+
destination = pre.fund_eoa(1)
24+
contract_address = pre.deploy_contract(
25+
Op.CALL(
26+
gas=Op.GAS,
27+
address=destination,
28+
value=1,
29+
args_offset=0,
30+
args_size=0,
31+
ret_offset=0,
32+
ret_size=0,
33+
)
34+
+ Op.SSTORE(key=1, value=Op.BALANCE(address=destination))
35+
+ Op.SSTORE(key=2, value=Op.GAS),
36+
balance=0,
37+
)
38+
sender = pre.fund_eoa(0x3000000000)
39+
40+
tx = Transaction(
41+
chain_id=0x01,
42+
to=contract_address,
43+
value=0,
44+
gas_limit=323328,
45+
access_list=[],
46+
protected=True,
47+
sender=sender,
48+
)
49+
50+
post = {
51+
destination: Account(
52+
balance=1,
53+
),
54+
}
55+
state_test(env=env, pre=pre, post=post, tx=tx)

0 commit comments

Comments
 (0)