forked from ethereum/execution-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_callcode50000.py
More file actions
154 lines (141 loc) · 3.8 KB
/
test_callcode50000.py
File metadata and controls
154 lines (141 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""
Test_callcode50000.
Ported from:
state_tests/stQuadraticComplexityTest/Callcode50000Filler.json
@manually-enhanced: Do not overwrite. Post-state expectations corrected
manually (see PR #2784).
"""
import pytest
from execution_testing import (
Account,
Address,
Alloc,
Bytes,
Environment,
StateTestFiller,
Transaction,
)
from execution_testing.forks import Fork
from execution_testing.specs.static_state.expect_section import (
resolve_expect_post,
)
from execution_testing.vm import Op
REFERENCE_SPEC_GIT_PATH = "N/A"
REFERENCE_SPEC_VERSION = "N/A"
@pytest.mark.ported_from(
["state_tests/stQuadraticComplexityTest/Callcode50000Filler.json"],
)
@pytest.mark.valid_from("Cancun")
@pytest.mark.valid_until("Prague")
@pytest.mark.slow
@pytest.mark.parametrize(
"d, g, v",
[
pytest.param(
0,
0,
0,
id="-g0",
),
pytest.param(
0,
1,
0,
id="-g1",
),
],
)
@pytest.mark.pre_alloc_mutable
def test_callcode50000(
state_test: StateTestFiller,
pre: Alloc,
fork: Fork,
d: int,
g: int,
v: int,
) -> None:
"""Test_callcode50000."""
coinbase = Address(0xB94F5374FCE5EDBC8E2A8697C15331677E6EBF0B)
sender = pre.fund_eoa(amount=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
env = Environment(
fee_recipient=coinbase,
number=1,
timestamp=1000,
prev_randao=0x20000,
base_fee_per_gas=10,
gas_limit=8600000000,
)
addr = pre.fund_eoa(amount=7000)
# Source: lll
# { (def 'i 0x80) (for {} (< @i 50000) [i](+ @i 1) [[ 0 ]] (CALLCODE 1600 <eoa:0xaaaf5374fce5edbc8e2a8697c15331677e6ebf0b> 1 0 50000 0 0) ) [[ 1 ]] @i} # noqa: E501
target_code = (
Op.JUMPDEST
+ Op.JUMPI(
pc=0x3F, condition=Op.ISZERO(Op.LT(Op.MLOAD(offset=0x80), 0xC350))
)
+ Op.SSTORE(
key=0x0,
value=Op.CALLCODE(
gas=0x640,
address=addr,
value=0x1,
args_offset=0x0,
args_size=0xC350,
ret_offset=0x0,
ret_size=0x0,
),
)
+ Op.MSTORE(offset=0x80, value=Op.ADD(Op.MLOAD(offset=0x80), 0x1))
+ Op.JUMP(pc=0x0)
+ Op.JUMPDEST
+ Op.SSTORE(key=0x1, value=Op.MLOAD(offset=0x80))
+ Op.STOP
)
target = pre.deploy_contract(
code=target_code,
balance=0xFFFFFFFFFFFFF,
nonce=0,
)
expect_entries_: list[dict] = [
{
"indexes": {"data": -1, "gas": 1, "value": -1},
"network": [">=Cancun<Osaka"],
"result": {
sender: Account(storage={}, code=b"", nonce=1),
addr: Account(storage={}, code=b"", nonce=0),
target: Account(
storage={},
code=bytes(target_code),
nonce=0,
),
},
},
{
"indexes": {"data": -1, "gas": 0, "value": -1},
"network": [">=Cancun<Osaka"],
"result": {
sender: Account(storage={}, code=b"", nonce=1),
addr: Account(storage={}, code=b"", nonce=0),
target: Account(
storage={},
code=bytes(target_code),
nonce=0,
),
},
},
]
post, _exc = resolve_expect_post(expect_entries_, d, g, v, fork)
tx_data = [
Bytes(""),
]
tx_gas = [150000, 250000000]
tx_value = [10]
tx = Transaction(
sender=sender,
to=target,
data=tx_data[d],
gas_limit=tx_gas[g],
value=tx_value[v],
error=_exc,
)
state_test(env=env, pre=pre, post=post, tx=tx)