Skip to content

Create opcode test cases generator #1966

@marioevz

Description

@marioevz

For a future PR:

I think we can generalize these into a test generator:

Given (1) an Opcode, (2) a list of verification stack inputs/ouputs combinations, test the opcode in many different contexts and verify it works correctly, including Call-contexts, contract creation contexts, 7702 delegation context, etc.

Something like:

def generate_context_tests_for_opcode(
    opcode: Op,
    inputs_outputs: List[Tuple[List[int], int]],
):

And then on a test file you can do:

@generate_context_tests_for_opcode(
    opcode=Op.CLZ,
    inputs_outputs=[ ( [0x01], 0x01 ), ( [0xff], 256 - 8 ), ...
)
def test_clz_in_all_contexts(
...

Originally posted by @marioevz in #1829 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions