Skip to content

test_no_beacon_root_contract_at_transition()

Documentation for tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_no_beacon_root_contract_at_transition@49a16fac.

Generate fixtures for these test cases for Prague with:

fill -v tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py::test_no_beacon_root_contract_at_transition --fork Prague

Tests the fork transition to cancun in the case where the beacon root pre-deploy was not deployed in time for the fork.

Source code in tests/cancun/eip4788_beacon_root/test_beacon_root_contract.py
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
@pytest.mark.parametrize("timestamp", [15_000])
@pytest.mark.valid_at_transition_to("Cancun")
def test_no_beacon_root_contract_at_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    beacon_roots: Iterator[bytes],
    tx: Transaction,
    timestamp: int,
    caller_address: Address,
    fork: Fork,
):
    """
    Tests the fork transition to cancun in the case where the beacon root pre-deploy was not
    deployed in time for the fork.
    """
    assert fork.header_beacon_root_required(1, timestamp)
    blocks: List[Block] = [
        Block(
            txs=[tx],
            parent_beacon_block_root=next(beacon_roots),
            timestamp=timestamp,
            withdrawals=[
                # Also withdraw to the beacon root contract and the system address
                Withdrawal(
                    address=Spec.BEACON_ROOTS_ADDRESS,
                    amount=1,
                    index=0,
                    validator_index=0,
                ),
                Withdrawal(
                    address=Spec.SYSTEM_ADDRESS,
                    amount=1,
                    index=1,
                    validator_index=1,
                ),
            ],
        )
    ]
    pre[Spec.BEACON_ROOTS_ADDRESS] = Account(
        code=b"",  # Remove the code that is automatically allocated on Cancun fork
        nonce=0,
        balance=0,
    )
    post = {
        Spec.BEACON_ROOTS_ADDRESS: Account(
            storage={
                timestamp % Spec.HISTORY_BUFFER_LENGTH: 0,
                (timestamp % Spec.HISTORY_BUFFER_LENGTH) + Spec.HISTORY_BUFFER_LENGTH: 0,
            },
            code=b"",
            nonce=0,
            balance=int(1e9),
        ),
        caller_address: Account(
            storage={
                0: 1
            },  # Successful call because the contract is not there, but nothing else is stored
        ),
    }
    blockchain_test(
        pre=pre,
        blocks=blocks,
        post=post,
    )

Parametrized Test Cases

This test case is only parametrized by fork.

Test ID (Abbreviated) timestamp
...fork_ShanghaiToCancunAtTime15k-blockchain_test-timestamp_15000 15000