test_bal_delegated_storage_writes()
Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_delegated_storage_writes@2119b382.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py::test_bal_delegated_storage_writes --fork Amsterdam
Ensure BAL captures delegated storage writes via
DELEGATECALL and CALLCODE.
Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists.py
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427 | @pytest.mark.parametrize(
"delegated_opcode",
[
pytest.param(Op.DELEGATECALL, id="delegatecall"),
pytest.param(Op.CALLCODE, id="callcode"),
],
)
def test_bal_delegated_storage_writes(
pre: Alloc,
blockchain_test: BlockchainTestFiller,
delegated_opcode: Op,
) -> None:
"""
Ensure BAL captures delegated storage writes via
DELEGATECALL and CALLCODE.
"""
alice = pre.fund_eoa()
# TargetContract that writes 0x42 to slot 0x01
target_code = Op.SSTORE(0x01, 0x42)
target_contract = pre.deploy_contract(code=target_code)
# Oracle contract that uses delegated opcode to execute
# TargetContract's code
oracle_code = delegated_opcode(address=target_contract)
oracle_contract = pre.deploy_contract(code=oracle_code)
tx = Transaction(sender=alice, to=oracle_contract)
block = Block(
txs=[tx],
expected_block_access_list=BlockAccessListExpectation(
account_expectations={
alice: BalAccountExpectation(
nonce_changes=[
BalNonceChange(block_access_index=1, post_nonce=1)
],
),
oracle_contract: BalAccountExpectation(
storage_changes=[
BalStorageSlot(
slot=0x01,
slot_changes=[
BalStorageChange(
block_access_index=1, post_value=0x42
)
],
)
],
),
target_contract: BalAccountExpectation.empty(),
}
),
)
blockchain_test(pre=pre, blocks=[block], post={})
|
Parametrized Test Cases
This test generates 2 parametrized test cases across 1 fork.