Skip to content

test_delegation_replacement_call_previous_contract()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_delegation_replacement_call_previous_contract@64f949d0.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_delegation_replacement_call_previous_contract --fork Prague

Test setting the code of an EOA that already has delegation, calling the previous delegated contract. Previous contract shouldn't be warm when doing the CALL.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
@pytest.mark.valid_from("Prague")
def test_delegation_replacement_call_previous_contract(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
):
    """
    Test setting the code of an EOA that already has
    delegation, calling the previous delegated contract.
    Previous contract shouldn't be warm when doing the CALL.
    """
    pre_set_delegation_code = Op.STOP
    pre_set_delegation_address = pre.deploy_contract(pre_set_delegation_code)

    auth_signer = pre.fund_eoa(delegation=pre_set_delegation_address)
    sender = pre.fund_eoa()

    gsc = fork.gas_costs()
    overhead_cost = gsc.G_VERY_LOW * len(Op.CALL.kwargs)  # type: ignore
    set_code = CodeGasMeasure(
        code=Op.CALL(gas=0, address=pre_set_delegation_address),
        overhead_cost=overhead_cost,
        extra_stack_items=1,
    )

    set_code_to_address = pre.deploy_contract(
        set_code,
    )

    tx = Transaction(
        gas_limit=500_000,
        to=auth_signer,
        value=0,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=auth_signer.nonce,
                signer=auth_signer,
            ),
        ],
        sender=sender,
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            auth_signer: Account(
                storage={0: gsc.G_COLD_ACCOUNT_ACCESS},
            )
        },
    )

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test