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

Generate fixtures for these test cases for Osaka with:

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

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
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
@pytest.mark.parametrize("timestamp", [15_000])
@pytest.mark.valid_at_transition_to("Cancun")
@pytest.mark.pre_alloc_group(
    "beacon_root_no_contract", reason="This test removes the beacon root system contract"
)
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,
) -> None:
    """
    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(block_number=1, timestamp=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