Code Monkey home page Code Monkey logo

erc20-pbt's Introduction

ERC-20 pbt

A testing framework based in Property-based testing for assessing the correctness and compliance of ERC-20 contracts.
Thesis document »

Table of Contents

About the project

This project was developed by Célio Rodrigues in the context of a Master's thesis in Information security at FCUP, named Property-based testing of ERC-20 smart contracts and advised by Professor Eduardo Marques.

This ERC-20 testing framework is based upon the creation of a rule-based state machine model deployed on top of Brownie. Brownie is a Python-based development and testing framework for Ethereum smart contracts that extends the Hypothesis engine for property-based testing. The rule-based model is a general one, meaning that any ERC-20 contract can be tested at will. Moreover, it is extensible to other extra functionalities commonly found in contracts such as token minting, burning and sale. This project provides 8 real-world contracts and 2 reference implementations of ERC-20 to serve as testing examples.

Getting Started

Prerequisites

This testing framework has the following dependencies:

  • python3 version 3.6 or greater, python3-dev
  • ganache-cli version 6.8.2
  • Brownie v1.10.4 or greater

Installation

  1. Install pipx
python3 -m pip install --user pipx
python3 -m pipx ensurepath
  1. Install Brownie using pipx
pipx install eth-brownie
  1. Clone the repo
git clone https://github.com/celioggr/erc20-pbt.git

Usage

To facilitate the invocation of a property-based test with several configurable options, a simple shell script called pbt is used as a wrapper for the invocation of pytest. The invocation options relate to basic property-based testing parameters.

  • stateful step count
  • number of examples
  • test seed
  • optional shrinking of falsifying examples

Additionally, two operation modes can be enabled:

  • coverage monitoring
  • and debug output

Optional verification features can also be used to check for:

  • events
  • return values

Following is the usage message for the pbt script.

Usage :
pbt [ options ] test1...testn
Options :
−c <arg> : set stateful step count
−n <arg> : set maximum examples
−s <arg> : set seed for tests
−C : measure coverage
−D : enable debug output
−E : enable verification of events
−R : enable verification of return values
−S : enable shrinking

Contributing

Any contributions are welcome.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/Feature)
  3. Commit your Changes (git commit -m 'Add some Feature')
  4. Push to the Branch (git push origin feature/Feature)
  5. Open a Pull Request

License

Distributed under the Apache2.0 License. See LICENSE for more information.

Contact

erc20-pbt's People

Contributors

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