Skip to content

test_call_insufficient_balance()

Documentation for tests/berlin/eip2929_gas_cost_increases/test_call.py::test_call_insufficient_balance@e9958ed2.

Generate fixtures for these test cases for Osaka with:

fill -v tests/berlin/eip2929_gas_cost_increases/test_call.py::test_call_insufficient_balance --fork Osaka

Test a regular CALL to see if it warms the destination with insufficient balance.

Source code in tests/berlin/eip2929_gas_cost_increases/test_call.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@pytest.mark.valid_from("Berlin")
def test_call_insufficient_balance(
    state_test: StateTestFiller, pre: Alloc, env: Environment, fork: Fork
) -> None:
    """
    Test a regular CALL to see if it warms the destination with insufficient
    balance.
    """
    gas_costs = fork.gas_costs()
    destination = pre.fund_eoa(1)
    contract_address = pre.deploy_contract(
        # Perform the aborted external calls
        Op.SSTORE(
            0,
            Op.CALL(
                gas=Op.GAS,
                address=destination,
                value=1,
                args_offset=0,
                args_size=0,
                ret_offset=0,
                ret_size=0,
            ),
        )
        # Measure the gas cost for BALANCE operation
        + CodeGasMeasure(
            code=Op.BALANCE(destination),
            overhead_cost=gas_costs.G_VERY_LOW,  # PUSH20 costs 3 gas
            extra_stack_items=1,  # BALANCE puts balance on stack
            sstore_key=1,
        ),
        balance=0,
    )

    tx = Transaction(
        to=contract_address,
        gas_limit=100_000,
        sender=pre.fund_eoa(),
    )

    post = {
        destination: Account(
            balance=1,
        ),
        contract_address: Account(
            storage={
                0: 0,  # The CALL is aborted
                1: gas_costs.G_WARM_ACCOUNT_ACCESS,  # Warm access cost
            },
        ),
    }
    state_test(env=env, pre=pre, post=post, tx=tx)

Parametrized Test Cases

This test case is only parametrized by fork and fixture format.

Test ID (Abbreviated)
...fork_Berlin-state_test
...fork_Berlin-blockchain_test_from_state_test
...fork_London-state_test
...fork_London-blockchain_test_from_state_test
...fork_Paris-state_test
...fork_Paris-blockchain_test_from_state_test
...fork_Shanghai-state_test
...fork_Shanghai-blockchain_test_from_state_test
...fork_Cancun-state_test
...fork_Cancun-blockchain_test_from_state_test
...fork_Prague-state_test
...fork_Prague-blockchain_test_from_state_test
...fork_Osaka-state_test
...fork_Osaka-blockchain_test_from_state_test