Skip to content

test_slotnum_initcode_tx()

Documentation for tests/amsterdam/eip7843_slotnum/test_slotnum.py::test_slotnum_initcode_tx@ca7cac5c.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7843_slotnum/test_slotnum.py::test_slotnum_initcode_tx --fork Amsterdam

Test SLOTNUM inside the initcode of a contract-creating transaction.

Source code in tests/amsterdam/eip7843_slotnum/test_slotnum.py
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
@EIPChecklist.Opcode.Test.ExecutionContext.Initcode.Behavior()
@EIPChecklist.Opcode.Test.ExecutionContext.Initcode.Behavior.Tx()
def test_slotnum_initcode_tx(
    state_test: StateTestFiller,
    pre: Alloc,
) -> None:
    """
    Test SLOTNUM inside the initcode of a contract-creating transaction.
    """
    slot_number = 0xC0FFEE

    init_code = Op.SSTORE(0, Op.SLOTNUM)
    sender = pre.fund_eoa()
    contract_address = compute_create_address(address=sender, nonce=0)

    tx = Transaction(to=None, data=init_code, sender=sender)

    post = {
        contract_address: Account(storage={0: slot_number}),
    }

    state_test(
        env=Environment(slot_number=slot_number),
        pre=pre,
        tx=tx,
        post=post,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.