Skip to content

test_valid_containers()

Documentation for tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py::test_valid_containers --fork Osaka

Test various types of valid containers.

Source code in tests/osaka/eip7692_eof_v1/eip3540_eof_v1/test_container_validation.py
 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
 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
@pytest.mark.parametrize(
    "container",
    [
        Container(
            name="single_code_section_max_stack_size",
            sections=[
                Section.Code(
                    code=(Op.CALLER * MAX_OPERAND_STACK_HEIGHT)
                    + (Op.POP * MAX_OPERAND_STACK_HEIGHT)
                    + Op.STOP,
                    max_stack_height=MAX_OPERAND_STACK_HEIGHT,
                ),
            ],
        ),
        Container(
            name="code_section_with_inputs_outputs",
            sections=[
                Section.Code(
                    code=(Op.PUSH0 + Op.CALLF[1] + Op.STOP),
                ),
                Section.Code(
                    code=Op.POP + Op.PUSH0 + Op.RETF,
                    code_inputs=1,
                    code_outputs=1,
                ),
            ],
        ),
        Container(
            name="code_section_input_maximum",
            sections=[
                Section.Code(
                    code=((Op.PUSH0 * MAX_CODE_INPUTS) + Op.CALLF[1] + Op.STOP),
                    max_stack_height=MAX_CODE_INPUTS,
                ),
                Section.Code(
                    code=(Op.POP * MAX_CODE_INPUTS) + Op.RETF,
                    code_inputs=MAX_CODE_INPUTS,
                    code_outputs=0,
                    max_stack_height=MAX_CODE_INPUTS,
                ),
            ],
        ),
        Container(
            name="code_section_output_maximum",
            sections=[
                Section.Code(
                    code=(Op.CALLF[1] + Op.STOP),
                    max_stack_height=MAX_CODE_OUTPUTS,
                ),
                Section.Code(
                    code=(Op.PUSH0 * MAX_CODE_OUTPUTS) + Op.RETF,
                    code_inputs=0,
                    code_outputs=MAX_CODE_OUTPUTS,
                    max_stack_height=MAX_CODE_OUTPUTS,
                ),
            ],
        ),
        Container(
            name="multiple_code_sections",
            sections=[
                Section.Code(
                    Op.CALLF[1] + Op.STOP,
                ),
                Section.Code(
                    code=Op.RETF,
                    code_inputs=0,
                    code_outputs=0,
                ),
            ],
        ),
        Container(
            name="multiple_code_sections_max_inputs_max_outputs",
            sections=[
                Section.Code(
                    (Op.PUSH0 * MAX_CODE_OUTPUTS) + Op.CALLF[1] + Op.STOP,
                    max_stack_height=MAX_CODE_OUTPUTS,
                ),
                Section.Code(
                    code=Op.RETF,
                    code_inputs=MAX_CODE_INPUTS,
                    code_outputs=MAX_CODE_OUTPUTS,
                    max_stack_height=MAX_CODE_INPUTS,
                ),
            ],
        ),
        Container(
            name="single_subcontainer_without_data",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
                Section.Container(Container.Code(Op.INVALID)),
            ],
        ),
        Container(
            name="single_subcontainer_with_data",
            sections=[
                Section.Code(Op.EOFCREATE[0](0, 0, 0, 0) + Op.STOP),
                Section.Container(Container.Code(Op.INVALID)),
                Section.Data(data="0xAA"),
            ],
        ),
    ],
    ids=lambda c: c.name,
)
def test_valid_containers(
    eof_test: EOFTestFiller,
    container: Container,
):
    """Test various types of valid containers."""
    assert container.validity_error is None, (
        f"Valid container with validity error: {container.validity_error}"
    )
    eof_test(
        container=bytes(container),
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Test ID (Abbreviated) container
...fork_Osaka-eof_test-single_code_section_max_stack_size single_code_section_max_stack_size
...fork_Osaka-eof_test-code_section_with_inputs_outputs code_section_with_inputs_outputs
...fork_Osaka-eof_test-code_section_input_maximum code_section_input_maximum
...fork_Osaka-eof_test-code_section_output_maximum code_section_output_maximum
...fork_Osaka-eof_test-multiple_code_sections multiple_code_sections
...fork_Osaka-eof_test-multiple_code_sections_max_inputs_max_outputs multiple_code_sections_max_inputs_max_outputs
...fork_Osaka-eof_test-single_subcontainer_without_data single_subcontainer_without_data
...fork_Osaka-eof_test-single_subcontainer_with_data single_subcontainer_with_data