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@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_hash_mismatch --fork Amsterdam

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
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
@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,
        gas_limit=21_000,
    )

    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 1 fork.