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();
	}
}

Dependincies / 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 also need to install all of the package requirements, by calling

pip install -r requirements.txt

Architecture

img_2.png

Building Tests as CHCs-paths-tree

img_4.png

build project

forge build

run all tests

forge test

run specified test

forge test --match Loop*

run test generation for specified sol-file with Python

python3 ./scripts/SolidityTestGen.py -i ./src/Loop_1.sol

run test generation for folder with sol-files with Python

python3 ./scripts/RunAll.py -i folder_path -o ../testgen_output

Report example:

img_3.png

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

SolTg-0.0.2-py3-none-any.whl (23.4 MB view hashes)

Uploaded Python 3

Supported by

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