Solify
Solify is a powerful CLI tool that automatically generates comprehensive test suites for Solana Anchor programs. By analyzing your program's IDL (Interface Definition Language) file, Solify creates TypeScript test files with positive and negative test cases, handles account setup, PDA initialization, and provides an interactive interface for test generation.
Features
- Automated Test Generation: Generate complete test suites from IDL files
- Smart Analysis: Analyzes program dependencies, account ordering, and PDA requirements
- Comprehensive Coverage: Creates both positive and negative test cases
- Interactive TUI: Beautiful terminal user interface for guided test generation
- Transaction Inspector: Inspect and analyze Solana transactions
- Anchor Integration: Automatically detects and integrates with Anchor project structures
- Account Management: Handles keypair generation, airdrops, and PDA initialization
- On-chain Processing: Executes instructions on-chain to gather real transaction data
Installation
From crates.io (Recommended)
From Source
Requirements
- Rust 1.70+ (for building from source)
- Solana CLI tools (for transaction inspection)
- Node.js and Anchor (for running generated tests)
Quick Start
Generate Tests for Your Anchor Program
-
Navigate to your Anchor project:
-
Build your program to generate the IDL:
-
Run Solify to generate tests:
Or specify custom paths:
Or off-chain computation:
-
Follow the interactive prompts:
- Select the order of instructions to test
- Provide your wallet keypair path (default:
~/.config/solana/id.json) - Enter a paraphrase for test metadata
- Watch as Solify analyzes your program and generates tests
-
Run the generated tests:
Inspect a Transaction
Example:
Usage Guide
Command: gen-test
Generates comprehensive test suites for your Solana Anchor program.
Syntax:
Options:
-i, --idl <PATH>: Path to IDL file or directory containing IDL files (default:target/idl)-o, --output <PATH>: Output directory for generated test files (default:tests)--rpc-url <URL>: Solana RPC endpoint URL (default:https://api.devnet.solana.com)-v, --verbose: Enable verbose logging-off: For off chain computation
Examples:
# Use default paths (target/idl -> tests)
# Specify custom IDL file
# Specify custom output directory
# Use mainnet RPC (for production programs)
# Enable verbose output
# Enable off-chain computation
Interactive Flow:
- IDL Selection: Solify will automatically find IDL files in the specified directory
- Instruction Ordering: Select the order in which instructions should be tested
- Wallet Configuration: Provide the path to your wallet keypair
- Metadata: Enter a paraphrase/description for the test metadata
- Analysis: Solify analyzes your program structure, dependencies, and requirements
- On-chain Execution: Optionally executes instructions on-chain to gather real data
- Test Generation: Generates TypeScript test files with comprehensive test cases
Generated Test Structure:
The generated tests include:
- Setup code with keypair generation and airdrops
- PDA initialization for all required PDAs
- Positive test cases for each instruction
- Negative test cases with error handling
- Proper account management and signers
- TypeScript/Anchor test framework integration
Command: inspect
Inspect and analyze Solana transactions with a beautiful TUI interface.
Syntax:
Arguments:
SIGNATURE: Transaction signature to inspect
Examples:
# Inspect a transaction on devnet
)
Project Structure
solify/
├── cli/ # CLI application and user interface
├── parser/ # IDL parsing and analysis
├── analyzer/ # Program analysis (dependencies, PDAs, account ordering)
├── generator/ # Test file generation using templates
├── client/ # Solana RPC client for on-chain operations
├── common/ # Shared types, errors, and utilities
└── solana-program/ # On-chain Solana program (if applicable)
Key Components
- CLI: Command-line interface with interactive TUI
- Parser: Parses Anchor IDL files and extracts program structure
- Analyzer: Analyzes program dependencies, detects PDAs, determines account ordering
- Generator: Generates TypeScript test files using template engine
- Client: Handles Solana RPC interactions for on-chain data gathering
How It Works
- IDL Parsing: Reads and parses your Anchor program's IDL file
- Dependency Analysis: Analyzes instruction dependencies and execution order
- Account Analysis: Detects PDAs, determines account requirements, and ordering
- Test Case Generation: Creates positive and negative test cases for each instruction
- On-chain Execution (optional): Executes instructions on-chain to gather real transaction data
- Template Rendering: Generates TypeScript test files using Handlebars templates
- Integration: Outputs tests compatible with Anchor's test framework
Development
Building from Source
# Clone the repository
# Build the project
# Run tests
# Build the CLI
Running Examples
# Parse an IDL file
Project Dependencies
The project uses a Rust workspace with the following crates:
solify-common: Shared types and error definitionssolify-parser: IDL parsing functionalitysolify-analyzer: Program analysis logicsolify-generator: Test generation enginesolify-client: Solana RPC client wrapper
Configuration
Wallet Configuration
By default, Solify looks for your wallet at ~/.config/solana/id.json. You can specify a different path during the interactive flow or by modifying the default in the code.
Troubleshooting
Common Issues
Issue: "IDL file not found"
- Solution: Ensure you've built your Anchor program with
anchor build, or specify the correct path with--idl
Issue: "Failed to connect to RPC"
- Solution: Check your internet connection and RPC endpoint. Try a different RPC URL with
--rpc-url
Issue: "Wallet not found"
- Solution: Ensure your Solana wallet exists at
~/.config/solana/id.jsonor provide the correct path during the interactive flow
Issue: "Insufficient funds"
- Solution: Airdrop SOL to your wallet:
solana airdrop 2(on devnet)
Issue: "Generated tests fail"
- Solution: Review the generated test file and adjust account setup or instruction parameters as needed
Getting Help
- Check the Issues page
- Review the generated test files for debugging
- Enable verbose mode:
solify gen-test --verbose
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Acknowledgments
- Built for the Solana and Anchor ecosystems
- Inspired by the need for better testing tools in the Solana development workflow
Author
Aditya Sehrawat
- Email: sehrawataditya22@gmail.com
- GitHub: @adisehrawat
Made with pure Rustling mind for the Solana community