Skip to content

test_bal_invalid_storage_value()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_storage_value@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_storage_value --fork Bogota

Test that clients reject blocks where BAL contains incorrect storage values.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_storage_value(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject blocks where BAL contains incorrect storage
    values.
    """
    sender = pre.fund_eoa(amount=10**18)

    # Simple storage contract with canary values
    storage = Storage({1: 0, 2: 0, 3: 0})  # type: ignore
    contract = pre.deploy_contract(
        code=Op.SSTORE(1, 1) + Op.SSTORE(2, 2) + Op.SSTORE(3, 3),
        storage=storage.canary(),
    )

    tx = Transaction(sender=sender, to=contract)

    blockchain_test(
        pre=pre,
        post={
            sender: Account(balance=10**18, nonce=0),
            contract: Account(storage=storage.canary()),
        },
        blocks=[
            Block(
                txs=[tx],
                exception=BlockException.INVALID_BLOCK_ACCESS_LIST,
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        contract: BalAccountExpectation(
                            storage_changes=[
                                BalStorageSlot(
                                    slot=0x01,
                                    slot_changes=[
                                        BalStorageChange(
                                            block_access_index=1,
                                            post_value=0x01,
                                        )
                                    ],
                                ),
                                BalStorageSlot(
                                    slot=0x02,
                                    slot_changes=[
                                        BalStorageChange(
                                            block_access_index=1,
                                            post_value=0x02,
                                        )
                                    ],
                                ),
                                BalStorageSlot(
                                    slot=0x03,
                                    slot_changes=[
                                        BalStorageChange(
                                            block_access_index=1,
                                            post_value=0x03,
                                        )
                                    ],
                                ),
                            ],
                        ),
                    }
                ).modify(
                    # Corrupt storage value for slot 0x02
                    modify_storage(
                        contract, block_access_index=1, slot=0x02, value=0xFF
                    )
                ),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 2 forks.