Skip to content

Test Data Opcodes

Documentation for tests/prague/eip7692_eof_v1/eip7480_data_section/test_data_opcodes.py.

Generate fixtures for these test cases for Prague with:

Prague only:

fill -v tests/prague/eip7692_eof_v1/eip7480_data_section/test_data_opcodes.py --fork=Prague --evm-bin=/path/to/evm-tool-dev-version
For all forks up to and including Prague:
fill -v tests/prague/eip7692_eof_v1/eip7480_data_section/test_data_opcodes.py --until=Prague --evm-bin=/path/to/evm-tool-dev-version

Execution of DATA* opcodes within EOF V1 containers tests

test_data_section_succeed(state_test, pre, offset, datasize)

Test simple contracts that are simply expected to succeed on call.

Source code in tests/prague/eip7692_eof_v1/eip7480_data_section/test_data_opcodes.py
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
@pytest.mark.parametrize(
    ["offset", "datasize"],
    [
        pytest.param(0, 0, id="empty_zero"),
        pytest.param(0, 2, id="short_zero"),
        pytest.param(0, 32, id="exact_zero"),
        pytest.param(0, 64, id="large_zero"),
        pytest.param(32, 0, id="empty_32"),
        pytest.param(32, 34, id="short_32"),
        pytest.param(32, 64, id="exact_32"),
        pytest.param(32, 96, id="large_32"),
        pytest.param(0x5BFE, 0, id="empty_23k"),
        pytest.param(0x5BFE, 0x5C00, id="short_23k"),
        pytest.param(0x5BE0, 0x5D00, id="exact_23k"),
        pytest.param(0x2345, 0x5C00, id="large_23k"),
    ],
)
def test_data_section_succeed(
    state_test: StateTestFiller,
    pre: Alloc,
    offset: int,
    datasize: int,
):
    """
    Test simple contracts that are simply expected to succeed on call.
    """
    env = Environment()

    (container, expected_storage) = create_data_test(offset, datasize)
    callee_contract = pre.deploy_contract(code=container)
    entry_point = pre.deploy_contract(
        code=Op.SSTORE(0, Op.DELEGATECALL(Op.GAS, callee_contract, 0, 0, 0, 0)) + Op.STOP()
    )
    sender = pre.fund_eoa()

    tx = Transaction(
        to=entry_point,
        gas_limit=50000000,
        gas_price=10,
        protected=False,
        data="",
        sender=sender,
    )

    post = {entry_point: Account(storage=expected_storage)}

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