Skip to content

Commit 473438f

Browse files
committed
unit test for post state verification error
1 parent 23fe412 commit 473438f

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""
2+
Test suite for `ethereum_test` module.
3+
"""
4+
5+
import pytest
6+
7+
from ethereum_test_forks import Fork, Istanbul, London, Merge, Shanghai
8+
from evm_transition_tool import GethTransitionTool
9+
10+
from ..common import Account, Environment, Transaction
11+
from ..common.types import Storage
12+
from ..filling import fill_test
13+
from ..spec import BaseTestConfig, StateTest
14+
from ..vm.opcode import Opcodes as Op
15+
16+
17+
@pytest.mark.parametrize(
18+
"fork,enable_hive",
19+
[
20+
(Istanbul, False),
21+
(London, False),
22+
(Merge, True),
23+
(Shanghai, True),
24+
],
25+
)
26+
def test_post_expect_section(fork: Fork, enable_hive: bool):
27+
"""
28+
Test `ethereum_test.filler.fill_fixtures` with `StateTest` and post state verification.
29+
"""
30+
env = Environment()
31+
32+
pre = {
33+
0x1000000000000000000000000000000000000000: Account(code=Op.SSTORE(1, 1)),
34+
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b": Account(balance=1000000000000000000000),
35+
}
36+
37+
tx = Transaction(
38+
ty=0x0,
39+
chain_id=0x0,
40+
nonce=0,
41+
to="0x1000000000000000000000000000000000000000",
42+
gas_limit=100000000,
43+
gas_price=10,
44+
protected=False,
45+
)
46+
47+
post = {
48+
"0x1000000000000000000000000000000000000000": Account(storage={"0x01": "0x02"}),
49+
}
50+
51+
state_test = StateTest(
52+
env=env,
53+
pre=pre,
54+
post=post,
55+
txs=[tx],
56+
tag="my_chain_id_test",
57+
base_test_config=BaseTestConfig(enable_hive=enable_hive),
58+
)
59+
60+
t8n = GethTransitionTool()
61+
62+
wasError = False
63+
try:
64+
fixture = {
65+
f"000/my_chain_id_test/{fork}": fill_test(
66+
t8n=t8n,
67+
test_spec=state_test,
68+
fork=fork,
69+
spec=None,
70+
),
71+
}
72+
fixture.clear()
73+
except Storage.KeyValueMismatch as e:
74+
wasError = True
75+
assert e.want == 2
76+
assert e.got == 1
77+
assert e.key == 1
78+
assert e.address == "0x1000000000000000000000000000000000000000"
79+
assert wasError

0 commit comments

Comments
 (0)