Git Product home page Git Product logo

eos-contract-template's Introduction

CircleCI

eos-contract-template

A project template for the EOS contract.

Features

Requirements

name version
cmake 3.10+
GNU Make 4.1+
g++ 7+
eos.cdt 1.5.0
*docker 18.06.0-ce
*docker-compose 1.22.0

* is for running integration test

Directories & Files

  • Stander C++ sources

    • ./include/: C++ headers
    • ./cpp/: C++ imlementation
    • ./test/: unit test with Google Test

    Don't place source files which use #include <eosiolib/*> in these folders

  • EOS contract

    • ./contract/: EOS C++ files
  • Integration test

    • ./integration_test/
  • Script

    • ./clean_build.sh:
      1. clean folder ./build/*
      2. Build native excutable binary at ./build/mylib_test with unit test
      3. Build and output ./build/MyContract.abi and ./build/MyContract.wasm

Build

  • Run clean_build.sh

    bash clean_build.sh
    
  • Or, run in pre-build docker image

    docker run -it --rm --workdir $PWD --volume $PWD:$PWD yarencheng/eoscdt-docker bash clean_build.sh
    
  • Output

    • ./build/MyContract.abi
    • ./build/MyContract.wasm

Test

Here will execute unit test in the ./test folder. See Google Test for the detail

  • Run test.sh

    bash test.sh
    
  • Or, run in pre-build docker image

    docker run -it --rm --workdir $PWD --volume $PWD:$PWD yarencheng/eoscdt-docker bash test.sh
    

Integration Test

Here use cucumber for testing. It is a famous BDD testing framework.

  1. Put contract file in ./integration_test. For example:

    • ./integration_testMyContract.wasm
    • ./integration_testMyContract.abi
  2. Modify the contract path to be used. See before_all.js

    BeforeAll(function () {
    
        // ...
    
        // deploy contract
        cleos.setContract("myaccount", "./", "MyContract.wasm", "MyContract.abi")
    })
  3. Run docker-compose.

    docker-compose \
        --file integration_test/docker-compose.yaml \
        up \
        --exit-code-from=conntract_test \
        --abort-on-container-exit \
        --force-recreate \
        --build
    

    It will:

    • Run keosd in a container
    • Run nodeos in a container
    • Deploy contract to testnet
    • Run test with cucumuber-js

TODO list

  • Test with googletest
  • Build *.WASM file
  • integration test flow

eos-contract-template's People

Contributors

yarencheng avatar

Watchers

 avatar  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.