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@87aba1a3.

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
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
@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.