Skip to content

test_bal_call_with_value_in_static_context()

Documentation for tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_call_with_value_in_static_context@892e6d1e.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py::test_bal_call_with_value_in_static_context --fork Amsterdam

CALL with nonzero value in static context: target NOT in BAL.

Static check must fire before account access (warm/cold lookup, code loading).

Source code in tests/amsterdam/eip7928_block_level_access_lists/test_block_access_lists_opcodes.py
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
@pytest.mark.parametrize(
    "target_is_warm", [False, True], ids=["cold_target", "warm_target"]
)
@pytest.mark.parametrize(
    "target_has_code", [False, True], ids=["eoa_target", "contract_target"]
)
def test_bal_call_with_value_in_static_context(
    pre: Alloc,
    blockchain_test: BlockchainTestFiller,
    target_is_warm: bool,
    target_has_code: bool,
) -> None:
    """
    CALL with nonzero value in static context: target NOT in BAL.

    Static check must fire before account access (warm/cold lookup,
    code loading).
    """
    target_starting_balance = 1022
    if target_has_code:
        target = pre.deploy_contract(
            code=Op.STOP, balance=target_starting_balance
        )
    else:
        target = pre.fund_eoa(amount=target_starting_balance)

    caller_starting_balance = 10**18
    caller = pre.deploy_contract(
        code=Op.CALL(gas=100_000, address=target, value=1) + Op.STOP,
        balance=caller_starting_balance,
    )

    access_list = (
        [AccessList(address=target, storage_keys=[])]
        if target_is_warm
        else None
    )

    blockchain_test_under_static_call(
        pre,
        blockchain_test,
        static_call_target=caller,
        bal_expectations={target: None},
        post={
            caller: Account(balance=caller_starting_balance),
            target: Account(balance=target_starting_balance),
        },
        tx_access_list=access_list,
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 1 fork.