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@verkle@v0.0.6.

Generate fixtures for these test cases for Cancun with:

Cancun only:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_contract_timestamps --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Cancun:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_beacon_root_contract_timestamps --until=Cancun

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
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
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
@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,
):
    """
    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

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID system_address_balance auto_access_list timestamp valid_input
empty_system_address-auto_access_list_False-timestamp_12-valid_input_True 0 False 12 True
empty_system_address-auto_access_list_False-timestamp_4294967296-valid_input_True 0 False 4294967296 True
empty_system_address-auto_access_list_False-timestamp_18446744073709551614-valid_input_True 0 False 18446744073709551614 True
empty_system_address-auto_access_list_False-timestamp_18446744073709551615-valid_input_True 0 False 18446744073709551615 True
empty_system_address-auto_access_list_True-timestamp_12-valid_input_True 0 True 12 True
empty_system_address-auto_access_list_True-timestamp_4294967296-valid_input_True 0 True 4294967296 True
empty_system_address-auto_access_list_True-timestamp_18446744073709551614-valid_input_True 0 True 18446744073709551614 True
empty_system_address-auto_access_list_True-timestamp_18446744073709551615-valid_input_True 0 True 18446744073709551615 True
one_wei_system_address-auto_access_list_False-timestamp_12-valid_input_True 1 False 12 True
one_wei_system_address-auto_access_list_False-timestamp_4294967296-valid_input_True 1 False 4294967296 True
one_wei_system_address-auto_access_list_False-timestamp_18446744073709551614-valid_input_True 1 False 18446744073709551614 True
one_wei_system_address-auto_access_list_False-timestamp_18446744073709551615-valid_input_True 1 False 18446744073709551615 True
one_wei_system_address-auto_access_list_True-timestamp_12-valid_input_True 1 True 12 True
one_wei_system_address-auto_access_list_True-timestamp_4294967296-valid_input_True 1 True 4294967296 True
one_wei_system_address-auto_access_list_True-timestamp_18446744073709551614-valid_input_True 1 True 18446744073709551614 True
one_wei_system_address-auto_access_list_True-timestamp_18446744073709551615-valid_input_True 1 True 18446744073709551615 True
one_eth_system_address-auto_access_list_False-timestamp_12-valid_input_True 1000000000000000000 False 12 True
one_eth_system_address-auto_access_list_False-timestamp_4294967296-valid_input_True 1000000000000000000 False 4294967296 True
one_eth_system_address-auto_access_list_False-timestamp_18446744073709551614-valid_input_True 1000000000000000000 False 18446744073709551614 True
one_eth_system_address-auto_access_list_False-timestamp_18446744073709551615-valid_input_True 1000000000000000000 False 18446744073709551615 True
one_eth_system_address-auto_access_list_True-timestamp_12-valid_input_True 1000000000000000000 True 12 True
one_eth_system_address-auto_access_list_True-timestamp_4294967296-valid_input_True 1000000000000000000 True 4294967296 True
one_eth_system_address-auto_access_list_True-timestamp_18446744073709551614-valid_input_True 1000000000000000000 True 18446744073709551614 True
one_eth_system_address-auto_access_list_True-timestamp_18446744073709551615-valid_input_True 1000000000000000000 True 18446744073709551615 True