| Crates.io | traverse-codegen |
| lib.rs | traverse-codegen |
| version | 0.1.4 |
| created_at | 2025-09-19 03:10:50.181965+00 |
| updated_at | 2025-09-28 06:21:16.360212+00 |
| description | Code generation utilities for Solidity test generation and analysis |
| homepage | https://github.com/calltrace/traverse |
| repository | https://github.com/calltrace/traverse |
| max_upload_size | |
| id | 1845722 |
| size | 150,080 |
Code generation utilities for Solidity test suites and bindings.
This crate provides powerful code generation capabilities for Solidity projects, including automated test generation using Foundry framework and TypeScript/Rust bindings generation. It analyzes contract behavior to create comprehensive, ready-to-run test suites.
use traverse_codegen::{TestGenerator, TestFramework};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let generator = TestGenerator::new(TestFramework::Foundry);
// Generate tests for a contract
let tests = generator.generate_from_file("contracts/Token.sol")?;
// Write tests to file
tests.write_to_file("test/Token.t.sol")?;
Ok(())
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Test.sol";
import "../contracts/Token.sol";
contract TokenTest is Test {
Token token;
address alice = address(0x1);
address bob = address(0x2);
function setUp() public {
token = new Token("Test Token", "TST");
vm.deal(alice, 100 ether);
vm.deal(bob, 100 ether);
}
function testTransfer() public {
vm.prank(alice);
token.mint(alice, 1000);
vm.prank(alice);
token.transfer(bob, 100);
assertEq(token.balanceOf(bob), 100);
assertEq(token.balanceOf(alice), 900);
}
function testFuzzTransfer(uint256 amount) public {
vm.assume(amount > 0 && amount <= 1000);
// Fuzz test implementation
}
}
This crate powers the sol2test command-line tool:
# Generate Foundry tests
sol2test contracts/Token.sol -o test/Token.t.sol
# Generate with specific framework
sol2test contracts/*.sol --framework foundry --output test/
This crate is part of the Traverse suite of tools for Solidity code analysis, visualization, and test generation.
MIT OR Apache-2.0