Skip to content

test_slotnum_initcode_tx()

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

Generate fixtures for these test cases for Bogota with:

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

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

Source code in tests/amsterdam/eip7843_slotnum/test_slotnum.py
@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 2 forks.