Skip to content

test_beacon_root_equal_to_timestamp()

Documentation for tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_equal_to_timestamp@21507778.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_equal_to_timestamp --fork Amsterdam

Tests the beacon root contract call where the beacon root is equal to the timestamp.

The expected result is that the contract call will return the parent_beacon_block_root, as all timestamps used are valid.

Source code in tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py
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
@pytest.mark.parametrize(
    "beacon_root, timestamp",
    [
        (12, 12),  # twelve
        (2**32, 2**32),  # arbitrary
        (2**64 - 2, 2**64 - 2),  # near-max
        (2**64 - 1, 2**64 - 1),  # max
    ],
    indirect=["beacon_root"],
)
@pytest.mark.parametrize("auto_access_list", [False, True])
@pytest.mark.valid_from("Cancun")
def test_beacon_root_equal_to_timestamp(
    blockchain_test: BlockchainTestFiller,
    beacon_root: bytes,
    timestamp: int,
    pre: Alloc,
    tx: Transaction,
    post: Dict,
) -> None:
    """
    Tests the beacon root contract call where the beacon root is equal to the
    timestamp.

    The expected result is that the contract call will return the
    `parent_beacon_block_root`, as all timestamps used are valid.
    """
    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                parent_beacon_block_root=beacon_root,
                timestamp=timestamp,
            )
        ],
        post=post,
    )

Parametrized Test Cases

This test generates 8 parametrized test cases across 4 forks.