Skip to content

test_blobbasefee_during_fork()

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

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
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
@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.