Skip to content

Commit 5d3dd84

Browse files
committed
test scenarios
1 parent ff96593 commit 5d3dd84

File tree

17 files changed

+2166
-12
lines changed

17 files changed

+2166
-12
lines changed

converted-ethereum-tests.txt

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,120 @@
1+
([#808](https://github.com/ethereum/execution-spec-tests/pull/808))
2+
GeneralStateTests/stBadOpcode/invalidDiffPlaces.json
3+
GeneralStateTests/stBadOpcode/opc0CDiffPlaces.json
4+
GeneralStateTests/stBadOpcode/opc0DDiffPlaces.json
5+
GeneralStateTests/stBadOpcode/opc0EDiffPlaces.json
6+
GeneralStateTests/stBadOpcode/opc0FDiffPlaces.json
7+
GeneralStateTests/stBadOpcode/opc1EDiffPlaces.json
8+
GeneralStateTests/stBadOpcode/opc1FDiffPlaces.json
9+
GeneralStateTests/stBadOpcode/opc2ADiffPlaces.json
10+
GeneralStateTests/stBadOpcode/opc2BDiffPlaces.json
11+
GeneralStateTests/stBadOpcode/opc2CDiffPlaces.json
12+
GeneralStateTests/stBadOpcode/opc2DDiffPlaces.json
13+
GeneralStateTests/stBadOpcode/opc2EDiffPlaces.json
14+
GeneralStateTests/stBadOpcode/opc2FDiffPlaces.json
15+
GeneralStateTests/stBadOpcode/opc4ADiffPlaces.json
16+
GeneralStateTests/stBadOpcode/opc4BDiffPlaces.json
17+
GeneralStateTests/stBadOpcode/opc4CDiffPlaces.json
18+
GeneralStateTests/stBadOpcode/opc4DDiffPlaces.json
19+
GeneralStateTests/stBadOpcode/opc4EDiffPlaces.json
20+
GeneralStateTests/stBadOpcode/opc4FDiffPlaces.json
21+
GeneralStateTests/stBadOpcode/opc5CDiffPlaces.json
22+
GeneralStateTests/stBadOpcode/opc5DDiffPlaces.json
23+
GeneralStateTests/stBadOpcode/opc5EDiffPlaces.json
24+
GeneralStateTests/stBadOpcode/opc5FDiffPlaces.json
25+
GeneralStateTests/stBadOpcode/opc21DiffPlaces.json
26+
GeneralStateTests/stBadOpcode/opc22DiffPlaces.json
27+
GeneralStateTests/stBadOpcode/opc23DiffPlaces.json
28+
GeneralStateTests/stBadOpcode/opc24DiffPlaces.json
29+
GeneralStateTests/stBadOpcode/opc25DiffPlaces.json
30+
GeneralStateTests/stBadOpcode/opc26DiffPlaces.json
31+
GeneralStateTests/stBadOpcode/opc27DiffPlaces.json
32+
GeneralStateTests/stBadOpcode/opc28DiffPlaces.json
33+
GeneralStateTests/stBadOpcode/opc29DiffPlaces.json
34+
GeneralStateTests/stBadOpcode/opc49DiffPlaces.json
35+
GeneralStateTests/stBadOpcode/opcA5DiffPlaces.json
36+
GeneralStateTests/stBadOpcode/opcA6DiffPlaces.json
37+
GeneralStateTests/stBadOpcode/opcA7DiffPlaces.json
38+
GeneralStateTests/stBadOpcode/opcA8DiffPlaces.json
39+
GeneralStateTests/stBadOpcode/opcA9DiffPlaces.json
40+
GeneralStateTests/stBadOpcode/opcAADiffPlaces.json
41+
GeneralStateTests/stBadOpcode/opcABDiffPlaces.json
42+
GeneralStateTests/stBadOpcode/opcACDiffPlaces.json
43+
GeneralStateTests/stBadOpcode/opcADDiffPlaces.json
44+
GeneralStateTests/stBadOpcode/opcAEDiffPlaces.json
45+
GeneralStateTests/stBadOpcode/opcAFDiffPlaces.json
46+
GeneralStateTests/stBadOpcode/opcB0DiffPlaces.json
47+
GeneralStateTests/stBadOpcode/opcB1DiffPlaces.json
48+
GeneralStateTests/stBadOpcode/opcB2DiffPlaces.json
49+
GeneralStateTests/stBadOpcode/opcB3DiffPlaces.json
50+
GeneralStateTests/stBadOpcode/opcB4DiffPlaces.json
51+
GeneralStateTests/stBadOpcode/opcB5DiffPlaces.json
52+
GeneralStateTests/stBadOpcode/opcB6DiffPlaces.json
53+
GeneralStateTests/stBadOpcode/opcB7DiffPlaces.json
54+
GeneralStateTests/stBadOpcode/opcB8DiffPlaces.json
55+
GeneralStateTests/stBadOpcode/opcB9DiffPlaces.json
56+
GeneralStateTests/stBadOpcode/opcBADiffPlaces.json
57+
GeneralStateTests/stBadOpcode/opcBBDiffPlaces.json
58+
GeneralStateTests/stBadOpcode/opcBCDiffPlaces.json
59+
GeneralStateTests/stBadOpcode/opcBDDiffPlaces.json
60+
GeneralStateTests/stBadOpcode/opcBEDiffPlaces.json
61+
GeneralStateTests/stBadOpcode/opcBFDiffPlaces.json
62+
GeneralStateTests/stBadOpcode/opcC0DiffPlaces.json
63+
GeneralStateTests/stBadOpcode/opcC1DiffPlaces.json
64+
GeneralStateTests/stBadOpcode/opcC2DiffPlaces.json
65+
GeneralStateTests/stBadOpcode/opcC3DiffPlaces.json
66+
GeneralStateTests/stBadOpcode/opcC4DiffPlaces.json
67+
GeneralStateTests/stBadOpcode/opcC5DiffPlaces.json
68+
GeneralStateTests/stBadOpcode/opcC6DiffPlaces.json
69+
GeneralStateTests/stBadOpcode/opcC7DiffPlaces.json
70+
GeneralStateTests/stBadOpcode/opcC8DiffPlaces.json
71+
GeneralStateTests/stBadOpcode/opcC9DiffPlaces.json
72+
GeneralStateTests/stBadOpcode/opcCADiffPlaces.json
73+
GeneralStateTests/stBadOpcode/opcCBDiffPlaces.json
74+
GeneralStateTests/stBadOpcode/opcCCDiffPlaces.json
75+
GeneralStateTests/stBadOpcode/opcCDDiffPlaces.json
76+
GeneralStateTests/stBadOpcode/opcCEDiffPlaces.json
77+
GeneralStateTests/stBadOpcode/opcCFDiffPlaces.json
78+
GeneralStateTests/stBadOpcode/opcD0DiffPlaces.json
79+
GeneralStateTests/stBadOpcode/opcD1DiffPlaces.json
80+
GeneralStateTests/stBadOpcode/opcD2DiffPlaces.json
81+
GeneralStateTests/stBadOpcode/opcD3DiffPlaces.json
82+
GeneralStateTests/stBadOpcode/opcD4DiffPlaces.json
83+
GeneralStateTests/stBadOpcode/opcD5DiffPlaces.json
84+
GeneralStateTests/stBadOpcode/opcD6DiffPlaces.json
85+
GeneralStateTests/stBadOpcode/opcD7DiffPlaces.json
86+
GeneralStateTests/stBadOpcode/opcD8DiffPlaces.json
87+
GeneralStateTests/stBadOpcode/opcD9DiffPlaces.json
88+
GeneralStateTests/stBadOpcode/opcDADiffPlaces.json
89+
GeneralStateTests/stBadOpcode/opcDBDiffPlaces.json
90+
GeneralStateTests/stBadOpcode/opcDCDiffPlaces.json
91+
GeneralStateTests/stBadOpcode/opcDDDiffPlaces.json
92+
GeneralStateTests/stBadOpcode/opcDEDiffPlaces.json
93+
GeneralStateTests/stBadOpcode/opcDFDiffPlaces.json
94+
GeneralStateTests/stBadOpcode/opcE0DiffPlaces.json
95+
GeneralStateTests/stBadOpcode/opcE1DiffPlaces.json
96+
GeneralStateTests/stBadOpcode/opcE2DiffPlaces.json
97+
GeneralStateTests/stBadOpcode/opcE3DiffPlaces.json
98+
GeneralStateTests/stBadOpcode/opcE4DiffPlaces.json
99+
GeneralStateTests/stBadOpcode/opcE5DiffPlaces.json
100+
GeneralStateTests/stBadOpcode/opcE6DiffPlaces.json
101+
GeneralStateTests/stBadOpcode/opcE7DiffPlaces.json
102+
GeneralStateTests/stBadOpcode/opcE8DiffPlaces.json
103+
GeneralStateTests/stBadOpcode/opcE9DiffPlaces.json
104+
GeneralStateTests/stBadOpcode/opcEADiffPlaces.json
105+
GeneralStateTests/stBadOpcode/opcEBDiffPlaces.json
106+
GeneralStateTests/stBadOpcode/opcECDiffPlaces.json
107+
GeneralStateTests/stBadOpcode/opcEDDiffPlaces.json
108+
GeneralStateTests/stBadOpcode/opcEEDiffPlaces.json
109+
GeneralStateTests/stBadOpcode/opcEFDiffPlaces.json
110+
GeneralStateTests/stBadOpcode/opcF6DiffPlaces.json
111+
GeneralStateTests/stBadOpcode/opcF7DiffPlaces.json
112+
GeneralStateTests/stBadOpcode/opcF8DiffPlaces.json
113+
GeneralStateTests/stBadOpcode/opcF9DiffPlaces.json
114+
GeneralStateTests/stBadOpcode/opcFBDiffPlaces.json
115+
GeneralStateTests/stBadOpcode/opcFCDiffPlaces.json
116+
GeneralStateTests/stBadOpcode/opcFEDiffPlaces.json
117+
1118
([#748](https://github.com/ethereum/execution-spec-tests/pull/748))
2119
GeneralStateTests/stBadOpcode/badOpcodes.json
3120
GeneralStateTests/stBugs/evmBytecode.json

src/ethereum_test_base_types/composite_types.py

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Base composite types for Ethereum test cases.
33
"""
4+
45
from dataclasses import dataclass
56
from typing import Any, ClassVar, Dict, SupportsBytes, Type, TypeAlias
67

@@ -24,6 +25,7 @@ class Storage(RootModel[Dict[StorageKeyValueType, StorageKeyValueType]]):
2425
root: Dict[StorageKeyValueType, StorageKeyValueType] = Field(default_factory=dict)
2526

2627
_current_slot: int = PrivateAttr(0)
28+
_hint_map: Dict[StorageKeyValueType, str] = {}
2729

2830
StorageDictType: ClassVar[TypeAlias] = Dict[
2931
str | int | bytes | SupportsBytes, str | int | bytes | SupportsBytes
@@ -92,13 +94,15 @@ class KeyValueMismatch(Exception):
9294
key: int
9395
want: int
9496
got: int
97+
hint: str
9598

96-
def __init__(self, address: Address, key: int, want: int, got: int, *args):
99+
def __init__(self, address: Address, key: int, want: int, got: int, hint: str = "", *args):
97100
super().__init__(args)
98101
self.address = address
99102
self.key = key
100103
self.want = want
101104
self.got = got
105+
self.hint = hint
102106

103107
def __str__(self):
104108
"""Print exception string"""
@@ -107,7 +111,7 @@ def __str__(self):
107111
label_str = f" ({self.address.label})"
108112
return (
109113
f"incorrect value in address {self.address}{label_str} for "
110-
+ f"key {Hash(self.key)}:"
114+
+ f"key {Hash(self.key)} ({self.hint}):"
111115
+ f" want {HexNumber(self.want)} (dec:{int(self.want)}),"
112116
+ f" got {HexNumber(self.got)} (dec:{int(self.got)})"
113117
)
@@ -128,9 +132,9 @@ def __setitem__(
128132
value: StorageKeyValueTypeConvertible | StorageKeyValueType,
129133
): # noqa: SC200
130134
"""Sets an item in the storage"""
131-
self.root[
132-
StorageKeyValueTypeAdapter.validate_python(key)
133-
] = StorageKeyValueTypeAdapter.validate_python(value)
135+
self.root[StorageKeyValueTypeAdapter.validate_python(key)] = (
136+
StorageKeyValueTypeAdapter.validate_python(value)
137+
)
134138

135139
def __delitem__(self, key: StorageKeyValueTypeConvertible | StorageKeyValueType):
136140
"""Deletes an item from the storage"""
@@ -182,7 +186,7 @@ def items(self):
182186
return self.root.items()
183187

184188
def store_next(
185-
self, value: StorageKeyValueTypeConvertible | StorageKeyValueType | bool
189+
self, value: StorageKeyValueTypeConvertible | StorageKeyValueType | bool, hint: str = ""
186190
) -> StorageKeyValueType:
187191
"""
188192
Stores a value in the storage and returns the key where the value is stored.
@@ -192,6 +196,7 @@ def store_next(
192196
"""
193197
slot = StorageKeyValueTypeAdapter.validate_python(self._current_slot)
194198
self._current_slot += 1
199+
self._hint_map[slot] = hint
195200
self[slot] = StorageKeyValueTypeAdapter.validate_python(value)
196201
return slot
197202

@@ -230,7 +235,11 @@ def must_contain(self, address: Address, other: "Storage"):
230235
raise Storage.MissingKey(key=key)
231236
elif self[key] != other[key]:
232237
raise Storage.KeyValueMismatch(
233-
address=address, key=key, want=self[key], got=other[key]
238+
address=address,
239+
key=key,
240+
want=self[key],
241+
got=other[key],
242+
hint=self._hint_map.get(key, ""),
234243
)
235244

236245
def must_be_equal(self, address: Address, other: "Storage | None"):
@@ -243,17 +252,33 @@ def must_be_equal(self, address: Address, other: "Storage | None"):
243252
for key in self.keys() & other.keys():
244253
if self[key] != other[key]:
245254
raise Storage.KeyValueMismatch(
246-
address=address, key=key, want=self[key], got=other[key]
255+
address=address,
256+
key=key,
257+
want=self[key],
258+
got=other[key],
259+
hint=self._hint_map.get(key, ""),
247260
)
248261

249262
# Test keys contained in either one of the storage objects
250263
for key in self.keys() ^ other.keys():
251264
if key in self:
252265
if self[key] != 0:
253-
raise Storage.KeyValueMismatch(address=address, key=key, want=self[key], got=0)
266+
raise Storage.KeyValueMismatch(
267+
address=address,
268+
key=key,
269+
want=self[key],
270+
got=0,
271+
hint=self._hint_map.get(key, ""),
272+
)
254273

255274
elif other[key] != 0:
256-
raise Storage.KeyValueMismatch(address=address, key=key, want=0, got=other[key])
275+
raise Storage.KeyValueMismatch(
276+
address=address,
277+
key=key,
278+
want=0,
279+
got=other[key],
280+
hint=self._hint_map.get(key, ""),
281+
)
257282

258283
def canary(self) -> "Storage":
259284
"""

src/ethereum_test_forks/forks/forks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def valid_opcodes(
468468
"""
469469
Returns the list of Opcodes that are valid to work on this fork.
470470
"""
471-
return [Opcodes.RETURNDATASIZE, Opcodes.STATICCALL] + super(Byzantium, cls).valid_opcodes()
471+
return [Opcodes.REVERT, Opcodes.RETURNDATASIZE, Opcodes.STATICCALL] + super(Byzantium, cls).valid_opcodes()
472472

473473

474474
class Constantinople(Byzantium):

src/ethereum_test_vm/opcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def __new__(
326326
instance.lambda_operation = lambda_operation
327327
return instance
328328

329-
def __call__(self, *args_t: OpcodeCallArg) -> Bytecode:
329+
def __call__(self, *args_t: OpcodeCallArg, **kwargs) -> Bytecode:
330330
"""
331331
Performs the macro operation if any.
332332
Otherwise is a no-op.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Scenarios common import
3+
"""

0 commit comments

Comments
 (0)