EOF Tools for Test Generation

Tools for generating test cases for the EOF project.

Install

Option 1: Install individual commands (i.e. eof_gen):

go install github.com/hugo-dc/eofscripts/cmd/eof_gen@latest

Option 2: Install all commands:

go install github.com/hugo-dc/eofscripts/cmd/...@latest

Tools

mnem2evm

Converts a mnemonics to EVM bytecode.

Examples:

Simple conversion

mnem2evm "PUSH1(1) PUSH1(2) SSTORE STOP"

Result:

600160015500

Use tags in Relative Jumps:

mnem2evm "PUSH0 RJUMPI(end) RJUMP(start) end: PUSH1(1) PUSH1(1) SSTORE STOP start: RJUMP(end)"

Result:

5fe10003e00006600160015500e0fff7

Repeat Instructions:

mnem2evm "PUSH1(1) DUP1 * 8 STOP"

Repeats the instruction DUP1 8 times.

Result:

6001808080808080808000

evm2mnem

Converts EVM bytecode to mnemonics.

Example:

Simple conversion

Convert the result of the previous mnem2evm example using tags:

evm2mnem 5fe10003e00006600160015500e0fff7

Result:

PUSH0 RJUMPI(3) RJUMP(6) PUSH1(1) PUSH1(1) SSTORE STOP RJUMP(-9)

eof_gen

Generate EOF Code for the given EVM bytecode.

Examples:

Single EOF with one code section

eof_gen c:fe

Result:

ef000101000402000100010400000000800000fe

Simple EOF with one code section and data section:

eof_gen c:fe d:aabbcc

Result:

ef000101000402000100010400030000800000feaabbcc

EOF code with multiple code sections

eof_gen c:e50001 C:0:0:00

Note: Note that for code sections after the first the C prefix is used in the form: C:<inputs>:<outputs>:<code> (Max Stack Height is not necessary as it is calculated automatically).

Result:

ef000101000802000200030001040000000080000000800000e5000100

EOF code with multiple code sections and data section

eof_gen c:e50001 C:0:0:00 d:aabbcc

Result:

ef000101000802000200030001040003000080000000800000e5000100aabbcc

eof_desc

Receives valid EOF code as parameters and returns a description of the code.

Example, for the previous EOF code generated by the eof_gen example above:

eof_desc ef000101000802000200030001040003000080000000800000e5000100aabbcc

Result:

EF0001 # Magic and Version ( 1 )
010008 # Types length ( 8 )
020002 # Total code sections ( 2 )
  0003 # Code section  0 , 3  bytes
  0001 # Code section  1 , 1  bytes
040003 # Data section length ( 3 )
    00 # Terminator (end of header)
       # Code 0 types
    00 # 0 inputs
    80 # 0 outputs (Non-returning function)
  0000 # max stack: 0
       # Code 1 types
    00 # 0 inputs
    80 # 0 outputs (Non-returning function)
  0000 # max stack: 0
       # Code section 0
e50001 # [0] JUMPF(1) 
       # Code section 1
    00 # [0] STOP 
       # Data section 
aabbcc