Skip to content

test_blobbasefee_during_fork()

Documentation for tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py::test_blobbasefee_during_fork@ffe48572.

Generate fixtures for these test cases for Cancun with:

fill -v tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py::test_blobbasefee_during_fork --fork Cancun

Tests that the BLOBBASEFEE opcode results on exception when called before the fork and succeeds when called after the fork.

Source code in tests/cancun/eip7516_blobgasfee/test_blobgasfee_opcode.py
@pytest.mark.parametrize(
    "caller_pre_storage",
    [
        {
            block_number: 0xFF
            for block_number, _ in enumerate(timestamps, start=1)
        }
    ],
    ids=[""],
)
@pytest.mark.valid_at_transition_to("Cancun")
def test_blobbasefee_during_fork(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    caller_address: Address,
    callee_address: Address,
    tx: Transaction,
) -> None:
    """
    Tests that the BLOBBASEFEE opcode results on exception when called before
    the fork and succeeds when called after the fork.
    """
    code_caller_post_storage = Storage()

    nonce = count(0)

    blocks = []

    for block_number, timestamp in enumerate(timestamps, start=1):
        blocks.append(
            Block(
                txs=[tx.with_nonce(next(nonce))],
                timestamp=timestamp,
            ),
        )
        # pre-set storage just to make sure we detect the change
        code_caller_post_storage[block_number] = 0 if timestamp < 15_000 else 1

    post = {
        caller_address: Account(
            storage=code_caller_post_storage,
        ),
        callee_address: Account(
            balance=0,
        ),
    }
    blockchain_test(
        pre=pre,
        blocks=blocks,
        post=post,
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.