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
-
Python3 & pip
-
GenHtml (part or lcov)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file soltg-0.1.10.tar.gz
.
File metadata
- Download URL: soltg-0.1.10.tar.gz
- Upload date:
- Size: 22.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a4aa9a7866152ee59ae242f448491026f131e691efd492098c8370ee08f2156 |
|
MD5 | 70afa610b03eaddb8aeda4e2971957a3 |
|
BLAKE2b-256 | b42620099544e8570adbc947e8f941ecc45ba81f4c0bdc77699fff711a13f3c7 |
File details
Details for the file solTg-0.1.10-py3-none-any.whl
.
File metadata
- Download URL: solTg-0.1.10-py3-none-any.whl
- Upload date:
- Size: 22.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c509ec197655640a64ccc84bf069d26469bf5d30a960090d212cece8196baafb |
|
MD5 | 19b41f09ae13751663b54150e91699cc |
|
BLAKE2b-256 | a516e6d380a1d3c28f20f2cebe546a119aadcca0068a7b04d6a60a10e82f78cc |