Skip to content

test_beacon_root_contract_timestamps()

Documentation for tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_contract_timestamps@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

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

Tests the beacon root contract call across for various valid and invalid timestamps.

The expected result is that the contract call will return the correct parent_beacon_block_root for a valid input timestamp and return the zero'd 32 bytes value for an invalid input timestamp.

Source code in tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
@pytest.mark.parametrize(
    "timestamp, valid_input",
    [
        (0x0C, True),  # twelve
        (2**32, True),  # arbitrary
        (2**64 - 2, True),  # near-max
        (2**64 - 1, True),  # max
        # TODO: Update t8n to un marshal > 64-bit int
        # Exception: failed to evaluate: ERROR(10): failed un marshaling stdin
        # (2**64, False),  # overflow
        # Exception: failed to evaluate: ERROR(10): failed un marshaling stdin
        # (2**64 + 1, False),  # overflow+1
    ],
)
@pytest.mark.parametrize("auto_access_list", [False, True])
@pytest.mark.parametrize(
    "system_address_balance",
    [
        pytest.param(0, id="empty_system_address"),
        pytest.param(1, id="one_wei_system_address"),
        pytest.param(int(1e18), id="one_eth_system_address"),
    ],
)
@pytest.mark.valid_from("Cancun")
def test_beacon_root_contract_timestamps(
    blockchain_test: BlockchainTestFiller,
    beacon_root: bytes,
    timestamp: int,
    pre: Alloc,
    tx: Transaction,
    post: Dict,
) -> None:
    """
    Tests the beacon root contract call across for various valid and invalid
    timestamps.

    The expected result is that the contract call will return the correct
    `parent_beacon_block_root` for a valid input timestamp and return the
    zero'd 32 bytes value for an invalid input timestamp.
    """
    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                parent_beacon_block_root=beacon_root,
                timestamp=timestamp,
            )
        ],
        post=post,
    )

Parametrized Test Cases

This test generates 24 parametrized test cases across 4 forks.