Coder Social home page Coder Social logo

eofscripts's Introduction

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

eofscripts's People

Contributors

hugo-dc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.