Skip to content

guilledk/pytest-eosio

Repository files navigation

pytest-eosio

A pytest plugin for end-to-end testing EOSIO smart contracts

plugin running

What it does for you

  • Compile contracts (detects deltas on source files)

  • Create (or manage) a single node testnet acording to bios specification

  • Create staked accounts & deploy contracts acording to a manifest

  • Run tests that use one or more smart contracts against that fresh testnet

  • Write readable tests with python syntactic sugar

What it requires of you

  • Docker

  • Use cmake and eosiocdt 1.6.3 or 1.7.0 to compile your smart contracts (CMakeList.txt template available!)

  • Follow this directory structure on your project (command to init project with this structure planned):

project_root
│
└─── contracts
│    │
│    └─── contract1
│    │    │
│    │    └─── CMakeLists.txt
│    │    └─── other source files
│    │
│    |─── contract2
│    │    │
│    │    └─── CMakeLists.txt
│    │    └─── other source files
│    |
│    └─── manifest.toml
│
└─── tests, and other project files

Ok! but who uses it? give me an example

This plugin was created during the development of vapaee's smart contract suite.

Checkout the tests directory

That suite includes contracts and tests for:

  • A generic event tracking smart contract

  • A token-pool-converter with an open protocol

  • A decentralized book-style token market

  • Some of this contracts use Telos Decide ballot features

  • And more...

Cool! But, How does it work?

TODO

Install

1 - Install docker & python 3 (pyenv recommended)

2 - With python3 installed, run:

pip install git+git://github.com/guilledk/pytest-eosio.git

Usage

(IMPORTANT: Docker must be installed and running)

Run tests:

pytest $test_dir

Docker development commands

  • docker build:

    docker build --tag guilledk/pytest-eosio: docker/

  • docker push:

    docker push guilledk/pytest-eosio:

  • docker stop all:

    docker stop $(docker ps -q)

  • docker clear:

    docker system prune -a

Python Bindings Build

NEW!: experimental python bindings directly to native tester tools provided by EOSIO core: https://github.com/guilledk/py-eosio