Skip to content

test_bal_7702_invalid_authority_has_code_authorization()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py::test_bal_7702_invalid_authority_has_code_authorization@5c024cbb.

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_invalid_authority_has_code_authorization --fork Amsterdam

Ensure BAL handles failed authorization where the authority already has non-empty, non-delegation code (EIP-7702 step-5 rejection, post-load).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_eip7702.py
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
@pytest.mark.pre_alloc_mutable()
def test_bal_7702_invalid_authority_has_code_authorization(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
) -> None:
    """
    Ensure BAL handles failed authorization where the authority already has
    non-empty, non-delegation code (EIP-7702 step-5 rejection, post-load).
    """
    # Pre-existing non-delegation code on the authority blocks the 7702
    # delegation at step 5, after the authority is already loaded.
    alice = pre.fund_eoa(amount=0, code=Op.STOP, nonce=1)
    bob = pre.fund_eoa(amount=0)
    relayer = pre.fund_eoa()
    oracle = pre.deploy_contract(code=Op.STOP)

    tx = Transaction(
        sender=relayer,  # Sponsored transaction
        to=bob,
        value=10,
        authorization_list=[
            AuthorizationTuple(
                address=oracle,
                nonce=alice.nonce,
                signer=alice,
            )
        ],
    )

    block = Block(
        txs=[tx],
        expected_block_access_list=BlockAccessListExpectation(
            account_expectations={
                bob: BalAccountExpectation(
                    balance_changes=[
                        BalBalanceChange(block_access_index=1, post_balance=10)
                    ]
                ),
                relayer: BalAccountExpectation(
                    nonce_changes=[
                        BalNonceChange(block_access_index=1, post_nonce=1)
                    ],
                ),
                # Alice loaded at step 4 then step 5 rejects.
                alice: BalAccountExpectation.empty(),
                # Oracle never loaded as delegation target.
                oracle: None,
            }
        ),
    )

    post = {
        relayer: Account(nonce=1),
        bob: Account(balance=10),
        alice: Account(code=Op.STOP, nonce=1),
    }

    blockchain_test(
        pre=pre,
        blocks=[block],
        post=post,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.