test_bal_7702_delegated_via_call_opcode()
Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py::test_bal_7702_delegated_via_call_opcode@622620d8.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py::test_bal_7702_delegated_via_call_opcode --fork Amsterdam
Ensure BAL captures delegation target when a contract uses *CALL
opcodes to call a delegated account.
Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881 | @pytest.mark.with_all_call_opcodes
def test_bal_7702_delegated_via_call_opcode(
pre: Alloc,
blockchain_test: BlockchainTestFiller,
call_opcode: Op,
) -> None:
"""
Ensure BAL captures delegation target when a contract uses *CALL
opcodes to call a delegated account.
"""
# `oracle` contract that just returns successfully
oracle = pre.deploy_contract(code=Op.STOP)
# `alice` is a delegated account pointing to oracle
alice = pre.deploy_contract(
nonce=1,
code=Spec7702.delegation_designation(oracle),
balance=0,
)
# caller contract that uses `call_opcode` to call `alice`
caller = pre.deploy_contract(code=(call_opcode(address=alice) + Op.STOP))
bob = pre.fund_eoa()
tx = Transaction(
sender=bob,
to=caller, # `bob` calls caller contract
)
block = Block(
txs=[tx],
expected_block_access_list=BlockAccessListExpectation(
account_expectations={
bob: BalAccountExpectation(
nonce_changes=[
BalNonceChange(block_access_index=1, post_nonce=1)
],
),
caller: BalAccountExpectation.empty(),
# `alice` is accessed due to being the call target
alice: BalAccountExpectation.empty(),
# `oracle` appears in BAL due to delegation target access
oracle: BalAccountExpectation.empty(),
}
),
)
post = {bob: Account(nonce=1)}
blockchain_test(
pre=pre,
blocks=[block],
post=post,
)
|
Parametrized Test Cases
This test generates 4 parametrized test cases across 1 fork.