All Projects → meherett → pytest-eth

meherett / pytest-eth

Licence: MIT license
PyTest plugin for testing smart contracts for Ethereum blockchain.

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to pytest-eth

pytest-dependency
Manage dependencies of tests
Stars: ✭ 113 (+391.3%)
Mutual labels:  pytest, pytest-plugin
pytest-csv
CSV reporter for pytest.
Stars: ✭ 16 (-30.43%)
Mutual labels:  pytest, pytest-plugin
pytest-pycodestyle
pytest plugin to run pycodestyle
Stars: ✭ 15 (-34.78%)
Mutual labels:  pytest, pytest-plugin
awesome-solidity-gas-optimization
Best resources for Solidity gas optimizations ⛽
Stars: ✭ 893 (+3782.61%)
Mutual labels:  smart-contracts, ethereum-blockchain
pytest-elk-reporter
A plugin to send pytest test results to ELK stack
Stars: ✭ 17 (-26.09%)
Mutual labels:  pytest, pytest-plugin
pytest-datafiles
pytest plugin to create a tmpdir containing a preconfigured set of files and/or directories.
Stars: ✭ 75 (+226.09%)
Mutual labels:  pytest, pytest-plugin
pytest-subprocess
Pytest plugin to fake subprocess.
Stars: ✭ 83 (+260.87%)
Mutual labels:  pytest, pytest-plugin
Smart Contracts Example
Simple example of token market. Based on blockchain technology using Ethereum platform.
Stars: ✭ 37 (+60.87%)
Mutual labels:  smart-contracts, ethereum-blockchain
pytest-mock-server
Mock server plugin for pytest
Stars: ✭ 19 (-17.39%)
Mutual labels:  pytest, pytest-plugin
pytest-datafixtures
Data fixtures for pytest made simple
Stars: ✭ 24 (+4.35%)
Mutual labels:  pytest, pytest-plugin
overhave
Web-framework for BDD: scalable, configurable, easy to use, based on Flask Admin and Pydantic.
Stars: ✭ 61 (+165.22%)
Mutual labels:  pytest, pytest-plugin
pytest-pipeline
Pytest plugin for functional testing of data analysis pipelines
Stars: ✭ 19 (-17.39%)
Mutual labels:  pytest, pytest-plugin
pytest-neo
Matrix has you...
Stars: ✭ 44 (+91.3%)
Mutual labels:  pytest, pytest-plugin
pytest-involve
A pytest plugin to run tests pertaining to a specific file or changeset
Stars: ✭ 28 (+21.74%)
Mutual labels:  pytest, pytest-plugin
Seriality
Seriality is a library for serializing and de-serializing all the Solidity types in a very efficient way which mostly written in solidity-assembly
Stars: ✭ 105 (+356.52%)
Mutual labels:  smart-contracts, ethereum-blockchain
pytest-docker-tools
Opionated helpers for creating py.test fixtures for Docker integration and smoke testing environments
Stars: ✭ 61 (+165.22%)
Mutual labels:  pytest, pytest-plugin
Eventeum
A resilient Ethereum event listener that bridges your smart contract events and backend microservices
Stars: ✭ 272 (+1082.61%)
Mutual labels:  smart-contracts, ethereum-blockchain
React Ethereum Dapp Example
A starter boilerplate for an Ethereum dapp using web3.js v1.0, truffle, react, and parity
Stars: ✭ 384 (+1569.57%)
Mutual labels:  smart-contracts, ethereum-blockchain
web3scala
Scala library for integration with Ethereum clients
Stars: ✭ 24 (+4.35%)
Mutual labels:  smart-contracts, ethereum-blockchain
pytest-test-groups
A Pytest plugin that gives you a way to split your tests into groups of a specific size
Stars: ✭ 37 (+60.87%)
Mutual labels:  pytest, pytest-plugin

PyTest-Cobra PyPI - Python Version

PyTest plugin for testing Smart Contracts for Ethereum blockchain.

Build Status PyPI Version GitHub License Github Date PyPI Wheel Donate with Ethereum

Dependency

This library requires the solc executable to be present.

Only versions >=0.4.2 are supported and tested though this library may work with other versions.

solc installation instructions

Install Solidity compiler (solc) using Node Package Manager(npm)

npm install -g solc

or for Ubuntu(Linux)

sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc

Quickstart

Installation

pip install pytest-cobra

Development

Clone the repository and then run

pip install -e . -r requirements.txt

Usage

Execute your test suite

Example MetaCoin picture

# MetaCoin Testing

# cobra is pytest fixture
def test_metacoin(cobra):

    # Getting Contract Factory by name
    metacoin = cobra.contract('MetaCoin')
    
    # Getting Contract Instance of MetaCoin
    metacoin = metacoin.deploy()

    assert metacoin.getBalance(cobra.accounts[0]) == 10000

Running test from Solidity file (.sol)

pytest --cobra MetaCoin.sol

Optional commands

Import path remappings

solc provides path aliasing allow you to have more reusable project configurations.

pytest --cobra MetaCoin.sol --import_remappings ["zeppeling=/my-zeppelin-checkout-folder"]
Allow paths
pytest --cobra MetaCoin.sol --allow_paths "/home/meheret,/user,/"

Running test from compiled Contracts Json file (.json)

Compile your contracts into a package (soon to be ethPM-compliant)

solc --combined-json abi,bin,bin-runtime contracts/ > MetaCoin.json

Testing Contracts.json

pytest --cobra MetaCoin.json

Running test from Yaml file (.yaml)

test:
  artifact_path: "./build/contracts/"
  test_paths: ["./tests"]
  contracts: [
    contract: {
        artifact: "Contract.json",
        links: ["Contract.json"]
    }
  ]

Further help

PyTest

Go check out the PyTest.

Author ✒️

  • Meheret Tesfaye - Initial work - Cobra

License

This project is licensed under the MIT License - see the LICENSE file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].