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@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

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

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
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
@pytest.mark.valid_from("Prague")
@pytest.mark.xdist_group(name="bigmem")
def test_delegation_replacement_call_previous_contract(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    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)
    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