Skip to content

test_stack_access_set_code()

Documentation for tests/amsterdam/eip8024_dupn_swapn_exchange/test_execution_contexts.py::test_stack_access_set_code@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8024_dupn_swapn_exchange/test_execution_contexts.py::test_stack_access_set_code --fork Amsterdam

Test DUPN, SWAPN and EXCHANGE inside a set-code delegated account (EIP-7702).

Source code in tests/amsterdam/eip8024_dupn_swapn_exchange/test_execution_contexts.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
@EIPChecklist.Opcode.Test.ExecutionContext.SetCode()
def test_stack_access_set_code(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test DUPN, SWAPN and EXCHANGE inside a set-code delegated account
    (EIP-7702).
    """
    auth_signer = pre.fund_eoa(amount=0)
    set_code_to_address = pre.deploy_contract(stack_access_storage_code())

    tx = Transaction(
        to=auth_signer,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address,
                nonce=0,
                signer=auth_signer,
            ),
        ],
        sender=pre.fund_eoa(),
    )

    post = {
        set_code_to_address: Account(storage={}),
        auth_signer: Account(
            nonce=1,
            code=Spec7702.delegation_designation(set_code_to_address),
            storage=EXPECTED_STORAGE,
        ),
    }

    state_test(pre=pre, tx=tx, post=post)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.