Skip to content

test_slotnum_genesis()

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

Generate fixtures for these test cases for Amsterdam with:

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

Test that the slot number header field can be set at genesis.

The genesis header of this fixture carries a nonzero slot_number, so a client must decode the field to reproduce the genesis hash. The following block then exposes its own slot number via SLOTNUM.

Source code in tests/amsterdam/eip7843_slotnum/test_slotnum.py
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
@EIPChecklist.BlockHeaderField.Test.Genesis()
def test_slotnum_genesis(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that the slot number header field can be set at genesis.

    The genesis header of this fixture carries a nonzero `slot_number`,
    so a client must decode the field to reproduce the genesis hash.
    The following block then exposes its own slot number via SLOTNUM.
    """
    genesis_slot = 999
    block_slot = 1000

    contract = pre.deploy_contract(
        Op.SSTORE(0, Op.SLOTNUM), storage={0: 0xBA5E}
    )
    tx = Transaction(sender=pre.fund_eoa(), to=contract)

    blockchain_test(
        genesis_environment=Environment(slot_number=genesis_slot),
        pre=pre,
        blocks=[Block(slot_number=block_slot, txs=[tx])],
        post={contract: Account(storage={0: block_slot})},
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.