@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
)
),
)
],
)