Skip to content

bilal07karadeniz/TestForge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ TestForge - AI-Powered Smart Contract Testing Platform

License: MIT Node.js Monad Claude AI

TestForge is a comprehensive, AI-powered smart contract testing platform that automatically deploys, tests, and analyzes Solidity contracts on Monad Testnet. Built for the Monad Hackathon.

TestForge Banner


✨ Features

πŸ€– AI-Powered Analysis

  • Claude Sonnet 4.5 integration for intelligent contract analysis
  • Automatic test case generation based on contract logic
  • Security vulnerability detection
  • Gas optimization recommendations

πŸ§ͺ Comprehensive Testing

  • 100% function coverage - Tests every function in your contract
  • Expected vs Actual result comparison for every test
  • Transaction hashes for all write operations
  • Multi-wallet testing (owner/non-owner) for access control
  • Edge case testing (zero values, max uint256, overflow protection)
  • Parameter validation with automatic test data generation

πŸ“Š Advanced Analytics

  • Function Coverage Tracker - Ensure all functions are tested
  • Gas Metrics Dashboard - Track gas usage for every function
  • Security Findings - Categorized by severity (Critical/Warning/Info)
  • Gas Optimization Tips - Smart recommendations based on actual usage
  • Test History - Track improvements over time

🎯 Developer-Friendly

  • Export test results to CSV/JSON
  • Transaction explorer links for every deployment and test
  • Real-time progress tracking with percentages
  • Detailed error reporting with stack traces
  • Downloadable reports in multiple formats

πŸ”— Blockchain Integration

  • Monad Testnet deployment and testing
  • Automatic mock token deployment for ERC20/ERC721 contracts
  • Multi-network support (easily configurable)
  • Block explorer integration (Monadscan)

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ installed
  • Monad Testnet wallet with MON tokens
  • Anthropic API Key for AI features

Installation

# Clone the repository
git clone https://github.com/bilal07karadeniz/TestForge.git
cd TestForge

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

Configuration

  1. Backend Setup (backend/.env):
# Monad Network
MONAD_PRIVATE_KEY=your_private_key_here
MONAD_PRIVATE_KEY_2=second_wallet_for_testing
MONAD_RPC_URL=https://rpc.ankr.com/monad_testnet

# AI Configuration
ANTHROPIC_API_KEY=your_anthropic_api_key_here

# Server
PORT=3000
NODE_ENV=development
  1. Frontend Setup (optional - frontend/.env):
VITE_API_URL=http://localhost:3000

Running the Application

Terminal 1 - Backend:

cd backend
npm start

Terminal 2 - Frontend:

cd frontend
npm run dev

Open http://localhost:5173 in your browser.


πŸ“– Usage

1. Upload Your Contract

  • File Upload: Drag and drop your .sol file
  • Paste Code: Copy and paste your Solidity code directly

2. Automatic Analysis

The platform will automatically:

  1. βœ… Analyze contract dependencies (ERC20, ERC721, etc.)
  2. βœ… Deploy mock tokens if needed
  3. βœ… Compile the contract
  4. βœ… Deploy to Monad Testnet
  5. βœ… Execute comprehensive tests
  6. βœ… Generate AI security report

3. Review Results

View detailed results including:

  • Function Coverage: See which functions were tested
  • Test Results: Expected vs actual outcomes with transaction hashes
  • Gas Metrics: Analyze gas consumption across functions
  • Security Findings: AI-detected vulnerabilities
  • Optimization Tips: Recommendations to reduce gas costs

4. Export & Share

  • Download comprehensive reports
  • Export test data as CSV/JSON
  • Share results via unique URLs

πŸ—οΈ Architecture

TestForge/
β”œβ”€β”€ backend/                 # Node.js + Express backend
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ ai.service.js        # Claude AI integration
β”‚   β”‚   β”œβ”€β”€ deploy.service.js    # Contract compilation & deployment
β”‚   β”‚   β”œβ”€β”€ test.service.js      # Comprehensive testing engine
β”‚   β”‚   └── mock.service.js      # Mock token deployment
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── analyze.js           # API endpoints
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ monad.config.js      # Network configuration
β”‚   β”‚   └── scoring.js           # Score calculation
β”‚   └── server.js                # Express + Socket.IO server
β”‚
β”œβ”€β”€ frontend/                # React + Vite frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ ContractUpload.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ProgressTracker.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ResultsDashboard.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ TestResults.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FunctionCoverage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ GasMetrics.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ GasOptimizationTips.jsx
β”‚   β”‚   β”‚   └── SecurityFindings.jsx
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   └── api.js               # API client
β”‚   β”‚   └── utils/
β”‚   β”‚       └── constants.js         # Configuration
β”‚   └── index.html
β”‚
└── contracts/               # Sample contracts for testing

πŸ§ͺ Testing Features

Function Coverage

  • View Functions: Read-only contract state
  • Transaction Functions: State-changing operations
  • Parameterized Functions: Functions with inputs (automatic test data)
  • Access Control: Owner vs non-owner testing
  • Edge Cases: Zero values, max uint256, overflow tests
  • Payable Functions: ETH/MON transfer testing
  • Token Functions: ERC20/ERC721 interactions

Test Data Captured

Each test includes:

{
  "functionName": "increment",
  "type": "transaction",
  "status": "passed",
  "walletType": "owner",
  "parameters": [],
  "expectedResult": "Transaction executed successfully",
  "actualResult": "Transaction confirmed",
  "transactionHash": "0x1234...5678",
  "gasUsed": "43234",
  "blockNumber": 12345678
}

πŸ” Security Features

AI-Powered Detection

  • Reentrancy vulnerabilities
  • Integer overflow/underflow
  • Access control issues
  • Unprotected functions
  • Gas optimization opportunities

Severity Levels

  • πŸ”΄ Critical: Must fix before deployment
  • 🟑 Warning: Should be addressed
  • πŸ”΅ Info: Best practices and optimizations

πŸ“Š Example Output

=== Analysis Complete ===
Overall Score: 84/100 (Good)
Contract: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1

Test Results:
β”œβ”€β”€ Total: 27 tests
β”œβ”€β”€ Passed: 25 tests
β”œβ”€β”€ Failed: 2 tests
└── Coverage: 100%

Gas Analysis:
β”œβ”€β”€ Total Gas: 1,234,567
β”œβ”€β”€ Average: 45,724 per function
β”œβ”€β”€ Most Expensive: transfer() - 52,341 gas
└── Optimization Score: 85/100

Security Findings:
β”œβ”€β”€ Critical: 0
β”œβ”€β”€ Warnings: 3
└── Info: 5

πŸ› οΈ Tech Stack

Backend

  • Node.js + Express.js - Server framework
  • Socket.IO - Real-time communication
  • ethers.js - Blockchain interactions
  • solc - Solidity compiler
  • Anthropic Claude API - AI analysis

Frontend

  • React - UI framework
  • Vite - Build tool
  • Tailwind CSS - Styling
  • Framer Motion - Animations
  • Socket.IO Client - Real-time updates

Blockchain

  • Monad Testnet - Deployment network
  • Hardhat - Development environment

🎯 Use Cases

For Developers

  • βœ… Test contracts before mainnet deployment
  • βœ… Identify gas optimization opportunities
  • βœ… Verify function behavior with real blockchain state
  • βœ… Ensure access control is properly implemented

For Auditors

  • βœ… Automated security analysis
  • βœ… Comprehensive test coverage reports
  • βœ… Transaction-level verification
  • βœ… Export data for further analysis

For Projects

  • βœ… CI/CD integration for continuous testing
  • βœ… Track improvements over multiple versions
  • βœ… Team collaboration with shareable results
  • βœ… Documentation generation

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Monad for the amazing blockchain platform
  • Anthropic for Claude AI
  • OpenZeppelin for smart contract standards
  • Hardhat team for development tools

πŸ“§ Contact

Bilal Karadeniz


πŸš€ Roadmap

  • Multi-chain support (Ethereum, Polygon, etc.)
  • Code generation (Hardhat tests, deployment scripts)
  • Test history and comparison
  • Attack vector simulation
  • Differential testing (compare versions)
  • Interactive test builder
  • Team workspaces
  • CI/CD integration

Built with ❀️ for the Monad Hackathon

Report Bug Β· Request Feature

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors