Skip to content

test_pointer_normal()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_normal@20373115.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py::test_pointer_normal --fork Amsterdam

Tx -> call -> pointer A -> contract.

Other normal tx can interact with previously assigned pointers.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
@pytest.mark.valid_from("Prague")
@pytest.mark.parametrize("sender_delegated", [True, False])
@pytest.mark.parametrize("sender_is_auth_signer", [True, False])
def test_pointer_normal(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    sender_delegated: bool,
    sender_is_auth_signer: bool,
) -> None:
    """
    Tx -> call -> pointer A -> contract.

    Other normal tx can interact with
    previously assigned pointers.
    """
    env = Environment()

    storage: Storage = Storage()

    if sender_delegated:
        sender_delegation_target = pre.deploy_contract(Op.STOP)
        sender = pre.fund_eoa(delegation=sender_delegation_target)
    else:
        sender = pre.fund_eoa()

    if sender_is_auth_signer:
        pointer_a = sender
    else:
        pointer_a = pre.fund_eoa()

    slot_worked = storage.store_next(3, "contract_a_worked")
    contract_a = pre.deploy_contract(
        code=Op.SSTORE(slot_worked, Op.ADD(1, Op.SLOAD(slot_worked)))
        + Op.STOP,
    )
    nonce = 1 if sender_delegated else 0

    tx = Transaction(
        to=pointer_a,
        gas_limit=1_000_000,
        data=b"",
        value=0,
        sender=sender,
        authorization_list=[
            AuthorizationTuple(
                address=contract_a,
                nonce=(nonce := nonce + 1) if sender_is_auth_signer else 0,
                signer=pointer_a,
            )
        ],
    )

    # Other normal tx can interact with previously assigned pointers
    tx_2 = Transaction(
        to=pointer_a,
        gas_limit=1_000_000,
        data=b"",
        value=0,
        sender=sender,
        nonce=(nonce := nonce + 1),
    )

    # Event from another block
    tx_3 = Transaction(
        to=pointer_a,
        gas_limit=1_000_000,
        data=b"",
        value=0,
        sender=sender,
        nonce=(nonce := nonce + 1),
    )

    post = {pointer_a: Account(storage=storage)}
    blockchain_test(
        genesis_environment=env,
        pre=pre,
        post=post,
        blocks=[Block(txs=[tx, tx_2]), Block(txs=[tx_3])],
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 3 forks.