Skip to main content

Mutation testing framework for Solidity contracts

Project description

solidity-mutate

Mutation testing framework for Solidity contracts.

Version: v0.1.1

Install

If you are using the published package from PyPI:

pip install solidity-mutate==0.1.1

If you want to work on the repository locally:

git clone https://github.com/sidarth16/solidity-mutate.git
cd solidity-mutate
pip install -e .

Run

Run the tool from the repo root against the bundled Foundry example:

solidity-mutate examples/test_contract --safe

You can also run it as a module:

python3 -m solidity_mutate examples/test_contract --safe

To inspect the available mutators:

solidity-mutate --list-mutators

CLI Arguments

  • target
    • Path to the Solidity project root.
    • Default: ..
  • --file
    • Mutate only one Solidity file relative to the project root.
    • Example: contracts/token.sol
  • --test-cmd
    • Command used to run tests for each mutant.
    • Default: forge test
  • --mutators
    • Comma-separated mutators to run.
    • Default: all
  • --timeout
    • Timeout in seconds for each test command run.
    • Default: 30
  • --safe
    • Run a preflight test before mutation and a postflight test after mutation.
  • -v
    • Increase verbosity.
    • Use -v for summaries and -vv for full mutant logs.
  • --list-mutators
    • Print the available mutators and exit.

Repository Layout

  • src/solidity_mutate/: installable Python package
  • examples/test_contract/: Foundry sample project used by the mutator
  • pyproject.toml: package metadata and console script entrypoint

Sample Project

Run the bundled Foundry example directly:

cd examples/test_contract
forge test

Sample Results

The bundled example project currently reaches:

  • 100% line coverage
  • 100% statement coverage
  • 55.56% mutation score

Coverage Report

Coverage report

Mutation Report

Mutation report

-vv Sample Output

Verbose mutation output

Full Output

Full mutation output

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

solidity_mutate-0.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

solidity_mutate-0.1.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file solidity_mutate-0.1.1.tar.gz.

File metadata

  • Download URL: solidity_mutate-0.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.10

File hashes

Hashes for solidity_mutate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 616c87e3fc0d8a2dfadf5f3dc95c06a6add3acdd4dd0dd4750986fc3117572f5
MD5 1e226dd92b4067bef0972155b520e7d9
BLAKE2b-256 4a76b99356763074b18be38b70fb917b09009f32e43b9eb46bc7d7b07bd89bdc

See more details on using hashes here.

File details

Details for the file solidity_mutate-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for solidity_mutate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 913d0d173d4d735270368a475b69089c8ba4c2ccd1aabcfd912394aadbabb817
MD5 d6702244809f6bf81b73f73b00fc8e3b
BLAKE2b-256 8b3686ca2d56f5a06a1ac445188f96423ab5f95ce52d89bcefe129abc3b80853

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page