Skip to content

Commit 0a11037

Browse files
winsvegamarioevz
andauthored
feat(test): test opcode programs in different scenarios (#808)
* test scenarios * format with ruff * address some comments * fix invalid opcodes rebase * generate 1 test block per scenario per program * fix style * fix all_opcodes test * refactor with test program class * fix(tests): Delete updated static tests * fix(tests): skip on execute due to `Op.GASPRICE` --------- Co-authored-by: Mario Vega <marioevz@gmail.com>
1 parent 33df23d commit 0a11037

File tree

132 files changed

+2405
-94683
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2405
-94683
lines changed

converted-ethereum-tests.txt

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,124 @@ BlockchainTests/InvalidBlocks/bcEIP1559/intrinsicOrFailCancun.json
88
GeneralStateTests/VMTests/vmTests/calldataload.json
99
GeneralStateTests/VMTests/vmTests/calldatasize.json
1010

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

src/ethereum_test_forks/forks/forks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ def fn(
199199
assert authorization_list_or_count is None, (
200200
f"Authorizations are not supported in {cls.name()}"
201201
)
202+
202203
intrinsic_cost: int = gas_costs.G_TRANSACTION
203204

204205
if contract_creation:
@@ -642,7 +643,12 @@ def valid_opcodes(
642643
cls,
643644
) -> List[Opcodes]:
644645
"""Return list of Opcodes that are valid to work on this fork."""
645-
return [Opcodes.RETURNDATASIZE, Opcodes.STATICCALL] + super(Byzantium, cls).valid_opcodes()
646+
return [
647+
Opcodes.REVERT,
648+
Opcodes.RETURNDATASIZE,
649+
Opcodes.RETURNDATACOPY,
650+
Opcodes.STATICCALL,
651+
] + super(Byzantium, cls).valid_opcodes()
646652

647653

648654
class Constantinople(Byzantium):

src/ethereum_test_vm/opcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def __new__(
312312
instance.lambda_operation = lambda_operation
313313
return instance
314314

315-
def __call__(self, *args_t: OpcodeCallArg) -> Bytecode:
315+
def __call__(self, *args_t: OpcodeCallArg, **kwargs) -> Bytecode:
316316
"""Perform macro operation if any. Otherwise is a no-op."""
317317
if self.lambda_operation is not None:
318318
return self.lambda_operation(*args_t)

tests/frontier/opcodes/test_all_opcodes.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def prepare_stack(opcode: Opcode) -> Bytecode:
3434
return Op.PUSH1(1) + Op.PUSH1(5)
3535
if opcode == Op.JUMP:
3636
return Op.PUSH1(3)
37+
if opcode == Op.RETURNDATACOPY:
38+
return Op.PUSH1(0) * 3
3739
return Op.PUSH1(0x01) * 32
3840

3941

@@ -68,7 +70,7 @@ def test_all_opcodes(state_test: StateTestFiller, pre: Alloc, fork: Fork):
6870
Op.PUSH1(opcode.int()),
6971
# Limit gas to limit the gas consumed by the exceptional aborts in each
7072
# subcall that uses an undefined opcode.
71-
Op.CALL(50_000, opcode_address, 0, 0, 0, 0, 0),
73+
Op.CALL(35_000, opcode_address, 0, 0, 0, 0, 0),
7274
)
7375
for opcode, opcode_address in code_contract.items()
7476
)
@@ -78,13 +80,19 @@ def test_all_opcodes(state_test: StateTestFiller, pre: Alloc, fork: Fork):
7880

7981
post = {
8082
contract_address: Account(
81-
storage={**{opcode.int(): 1 for opcode in fork.valid_opcodes()}, code_worked: 1}
83+
storage={
84+
**{
85+
opcode.int(): 1 if opcode != Op.REVERT else 0
86+
for opcode in fork.valid_opcodes()
87+
},
88+
code_worked: 1,
89+
}
8290
),
8391
}
8492

8593
tx = Transaction(
8694
sender=pre.fund_eoa(),
87-
gas_limit=15_000_000,
95+
gas_limit=9_000_000,
8896
to=contract_address,
8997
data=b"",
9098
value=0,

tests/frontier/scenarios/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Scenarios common import."""

0 commit comments

Comments
 (0)