Skip to main content

Test generation for Solidity in Foundry format (https://github.com/foundry-rs/foundry).

Project description

solidity_testgen

Test generation for Solidity in Foundry format (https://github.com/foundry-rs/foundry)

Example of Contract under Test:

contract C {

    uint x;

	function f(uint _x) public {}
	function g(uint _x, uint _y) public {}
	function w(uint _x) public {}


	function i(uint _x) internal {}
}

Expected results of Test Generation:

import "forge-std/Test.sol";
import "../src/contract_under_test.sol";

contract contract_under_test_Test is Test {
	C c0, c1, c2, ... cN;

	function setUp() public {
		c0 = new C(); c1 = new C(); ... cN = new C();
	}
	function test_0() public {
		c0.f();
		c0.g();
		....
		c0.w();
	}
........
    function test_n() public {
		cN.g();
		cN.w();
		....
		cN.w();
	}
}

Dependencies / Setup

Also don't forget to get your user permission to interact with docker: https://stackoverflow.com/questions/48957195/how-to-fix-docker-got-permission-denied-issue

After dependencies are installed, you can install the package by calling:

sudo pip3 install solTg

After this, solTg can be used from any directory, calling the command:

solTg -i <input file/directory with .sol files>

Or you can run it locally, it is needed to install all the package requirements first, by calling

pip install -r requirements.txt

run test generation for specified sol-file with Python

solTg -i ./src/Loop_1.sol

You can also give specific output dir:

solTg -i folder_path -o ../testgen_output

If project is to be run from the repo, call:

python3 ./solTg/RunAll.py -i <some file/dir>

Run forge project:

build project

forge build

run all tests

forge test

run specified test

forge test --match Loop*

Generate a report:

python3 ./scripts/ReportBuilder.py -i testgen_dir

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

soltg-0.2.2.tar.gz (23.0 MB view details)

Uploaded Source

Built Distribution

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

soltg-0.2.2-py3-none-any.whl (23.1 MB view details)

Uploaded Python 3

File details

Details for the file soltg-0.2.2.tar.gz.

File metadata

  • Download URL: soltg-0.2.2.tar.gz
  • Upload date:
  • Size: 23.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for soltg-0.2.2.tar.gz
Algorithm Hash digest
SHA256 5ec6d9ab6a9998d233e4a442b10108e77add525cb6c5670c532c5c90424e1939
MD5 68642c4fd43da4a5592239d617fdaa60
BLAKE2b-256 a5bd0baaa0688aefda94de6edb9bcf2bdd49bd4cb49f9fe1b2c968549bfeccdc

See more details on using hashes here.

File details

Details for the file soltg-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: soltg-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 23.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for soltg-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d927f377403850ff68a9d2d5a810bb9945d58831483816bd66c45420f5ec5782
MD5 ef695d0be474e7f4cc729de7b60998f5
BLAKE2b-256 7018027b52d6d89a7663aaf8ec5895d9b6bf6ccc744e396569a3090bb1c08b67

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