test_invalid_layout()
Documentation for tests/prague/eip6110_deposits/test_modified_contract.py::test_invalid_layout@7b8124a7.
Generate fixtures for these test cases for Osaka with:
fill -v tests/prague/eip6110_deposits/test_modified_contract.py::test_invalid_layout --fork Osaka
Test deposit contract emitting logs with invalid layouts (sizes/offsets).
Source code in tests/prague/eip6110_deposits/test_modified_contract.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 | @pytest.mark.parametrize(
"log_argument,value",
[
pytest.param(arg, val)
for arg in EVENT_ARGUMENTS
for val in EVENT_ARGUMENT_VALUES
],
)
@pytest.mark.exception_test
def test_invalid_layout(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
log_argument: str,
value: str,
) -> None:
"""
Test deposit contract emitting logs with invalid layouts (sizes/offsets).
"""
log_params = {**DEFAULT_DEPOSIT_REQUEST_LOG_DATA_DICT}
log_params[log_argument] = 0 if value == "zero" else 2**256 - 1 # type: ignore
deposit_request_log = create_deposit_log_bytes(**log_params) # type: ignore
bytecode = Om.MSTORE(deposit_request_log) + Op.LOG1(
0,
len(deposit_request_log),
Spec.DEPOSIT_EVENT_SIGNATURE_HASH,
)
bytecode += Op.STOP
pre[Spec.DEPOSIT_CONTRACT_ADDRESS] = Account(
code=bytecode,
nonce=1,
balance=0,
)
sender = pre.fund_eoa()
tx = Transaction(
to=Spec.DEPOSIT_CONTRACT_ADDRESS,
sender=sender,
gas_limit=100_000,
)
blockchain_test(
pre=pre,
blocks=[
Block(
txs=[tx],
exception=[
BlockException.INVALID_DEPOSIT_EVENT_LAYOUT,
],
),
],
post={},
)
|
Parametrized Test Cases
This test generates 20 parametrized test cases across 2 forks.