Testing
Test your smart contracts without deploying to the blockchain using Ghost testing and simulation.
Overview
AVM Studio provides powerful testing tools that let you verify your contracts work correctly before spending any ALGO on deployment.
Ghost Testing
Full contract simulation without blockchain
Simulation
Simulate transactions on deployed contracts
Ghost Testing
Ghost testing lets you test your contract's logic in a sandboxed environment without deploying to any network. It's the fastest way to verify your code works correctly.
Key Features
- No deployment needed - Test directly from your source code
- State tracking - See exactly how state changes with each call
- Execution traces - Step through execution opcode by opcode
- Cost analysis - See opcode usage and budget consumption
- Save test suites - Rerun tests after code changes
Creating a Test
- Build your contract successfully
- Open the Ghost panel (right sidebar)
- Click New Test
- Configure initial state (if needed)
- Add method calls in sequence
- Click Run Test
Simulation
Simulation lets you test transactions against deployed contracts without actually submitting them to the blockchain.
Use Cases
- Preview transaction results before signing
- Test method calls on live contracts
- Debug failing transactions
- Estimate execution costs
How It Works
- Build a transaction (or transaction group)
- Click Simulate instead of Sign & Submit
- Review the simulated results
- If satisfied, submit the real transaction
Understanding Test Results
After running a test, you'll see detailed results:
State Diff
Shows exactly what state changed:
- Added - New state keys created
- Modified - Existing values changed
- Removed - State keys deleted
Return Values
Each method call shows its return value (if any), decoded according to the ABI.
Execution Trace
For debugging, expand the execution trace to see each opcode executed, stack values, and scratch space.
Cost Breakdown
See how many opcodes each operation consumed and how close you are to the budget limit.
Testing Best Practices
- Test early, test often - Run Ghost tests after every significant change
- Test edge cases - Verify error handling and boundary conditions
- Test access control - Ensure unauthorized calls fail appropriately
- Save test suites - Build up a library of tests you can rerun
- Test on Testnet - Before Mainnet, always verify on Testnet