Skip to content

test_stack_underflow_no_log()

Documentation for tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_stack_underflow_no_log@c74f1a67.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py::test_stack_underflow_no_log --fork Amsterdam

Test that stack underflow during CALL/CREATE does NOT emit log.

Source code in tests/amsterdam/eip7708_eth_transfer_logs/test_transfer_logs.py
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
@pytest.mark.parametrize(
    "contract_code",
    [
        pytest.param(
            # CALL stack underflow: only push 6 items instead of 7
            Op.PUSH1(0)
            + Op.PUSH1(0)
            + Op.PUSH1(0)
            + Op.PUSH1(0)
            + Op.PUSH1(100)
            + Op.PUSH2(0x1234)
            + Op.CALL,
            id="call_stack_underflow",
        ),
        pytest.param(
            # CREATE stack underflow: only push 2 items instead of 3
            Op.PUSH1(0) + Op.PUSH1(0) + Op.CREATE,
            id="create_stack_underflow",
        ),
    ],
)
def test_stack_underflow_no_log(
    state_test: StateTestFiller,
    env: Environment,
    pre: Alloc,
    sender: EOA,
    contract_code: Bytecode,
) -> None:
    """Test that stack underflow during CALL/CREATE does NOT emit log."""
    contract = pre.deploy_contract(contract_code, balance=1000)

    tx = Transaction(
        sender=sender,
        to=contract,
        value=1000,
        expected_receipt=TransactionReceipt(logs=[]),  # TX fails, no logs
    )

    state_test(env=env, pre=pre, post={}, tx=tx)

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.