Skip to content

test_bal_invalid_hash_mismatch()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_hash_mismatch@636b5f17.

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_hash_mismatch --fork Bogota

Test that clients reject blocks where the BAL hash in the header does not match the actual BAL content.

Unlike other invalid BAL tests which corrupt the BAL content while keeping the header hash consistent with the corrupted data, this test keeps the BAL valid but injects a wrong hash into the header via rlp_modifier.

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
@EIPChecklist.BlockHeaderField.Test.ValueBehavior.Reject()
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_hash_mismatch(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject blocks where the BAL hash in the header
    does not match the actual BAL content.

    Unlike other invalid BAL tests which corrupt the BAL content while
    keeping the header hash consistent with the corrupted data, this
    test keeps the BAL valid but injects a wrong hash into the header
    via rlp_modifier.
    """
    sender = pre.fund_eoa(amount=10**18)
    receiver = pre.fund_eoa(amount=0)

    tx = Transaction(
        sender=sender,
        to=receiver,
        value=10**15,
    )

    blockchain_test(
        pre=pre,
        post={
            sender: Account(balance=10**18, nonce=0),
            receiver: None,
        },
        blocks=[
            Block(
                txs=[tx],
                rlp_modifier=Header(block_access_list_hash=Hash(1)),
                exception=[
                    BlockException.INVALID_BAL_HASH,
                    BlockException.INVALID_BLOCK_HASH,
                ],
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 2 forks.