Skip to content

test_bal_invalid_withdrawal_balance_value()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py::test_bal_invalid_withdrawal_balance_value@622620d8.

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_withdrawal_balance_value --fork Amsterdam

Test that clients reject blocks where BAL contains an incorrect balance value for an account modified only by a withdrawal.

Charlie receives a 10 gwei withdrawal in an empty block. BAL is corrupted by changing Charlie's post-balance to 999 instead of the correct 10_000_000_000 (10 gwei in wei).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_invalid.py
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
@pytest.mark.valid_from("Amsterdam")
@pytest.mark.exception_test
def test_bal_invalid_withdrawal_balance_value(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
) -> None:
    """
    Test that clients reject blocks where BAL contains an incorrect
    balance value for an account modified only by a withdrawal.

    Charlie receives a 10 gwei withdrawal in an empty block.
    BAL is corrupted by changing Charlie's post-balance to 999 instead
    of the correct 10_000_000_000 (10 gwei in wei).
    """
    charlie = pre.fund_eoa(amount=0)

    blockchain_test(
        pre=pre,
        post={
            charlie: None,
        },
        blocks=[
            Block(
                txs=[],
                withdrawals=[
                    Withdrawal(
                        index=0,
                        validator_index=0,
                        address=charlie,
                        amount=10,
                    )
                ],
                exception=BlockException.INVALID_BLOCK_ACCESS_LIST,
                expected_block_access_list=BlockAccessListExpectation(
                    account_expectations={
                        charlie: BalAccountExpectation(
                            balance_changes=[
                                BalBalanceChange(
                                    block_access_index=1,
                                    post_balance=10 * 10**9,
                                )
                            ],
                        ),
                    }
                ).modify(
                    modify_balance(charlie, block_access_index=1, balance=999)
                ),
            )
        ],
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.