# solana-testing-fuzzing

> LiteSVM/Mollusk/Trident testing for Solana: wrong-account attack matrix, invariants, mutation checks.

solana-testing-fuzzing is a free AI agent skill on Agensi by BanditXBT, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [BanditXBT](https://www.agensi.io/creators/banditxbt)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.0
- Last updated: 2026-11-21
- Security: scan passed (2026-11-21); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/solana-testing-fuzzing
- Tags: testing-debugging, web3-crypto, security

## About this skill

Security tests on Solana are mostly **negative tests with wrong accounts**. Test what an attacker can pass, not just the happy path.

- **LiteSVM / Mollusk:** in-process SVM, no validator, very fast; load program `.so`, set account state directly, advance clock/slots. Best for unit-level and property tests; Mollusk (Anza-maintained, Rust-only) is aimed at single-instruction testing with CU benchmarking, requires every account to be declared explicitly, and `mollusk-svm-programs-token` supplies the Token, Token-2022, and ATA programs for token tests. LiteSVM supports multi-language tests.
- **Bankrun / `solana-program-test`:** in-process bank with time warping and account injection (JS or Rust).
- **`anchor test`:** spins up `solana-test-validator`; slower; good for integration and client flows.
- **Trident (fuzzing framework for Anchor):** stateful, instruction-sequence fuzzing with invariant checks.
- **`solana-test-validator --clone <ACCOUNT> --url <rpc>`** (and `--clone-upgradeable-program`): bring real mainnet accounts (oracles, pools, mints) into a local test; pin the slot/time by snapshotting once and committing fixtures.

1. **Happy path + state assertions:** after each instruction, assert the full state delta (balances, counters, authorities), not just "no error".
2. **Negative/adversarial account tests (mandatory per instruction):**
   - wrong signer / missing signer
   - wrong owner program on state, oracle, token accounts
   - wrong account type with same layout (cosplay)
   - substituted PDA (wrong seeds/bump), non-canonical bump
   - duplicate accounts passed in two slots
   - fake program in place of token/system/own program (CPI target)
   - mismatched mint/authority on token accounts
   - uninitialized, already-initialized, and closed accounts
   - spoofed sysvar accounts
   - `remaining_accounts` with malicious entries
   Each must fail with the *expected* error code (assert the specific error, not just failure).
3. **Boundary & arithmetic:** zero, 1, max `u64`, decimals mix, rounding-direction checks, overflow behavior with release flags (`cargo build-sbf` uses release: test the built `.so`, not just debug unit tests).
4. **Time & slot:** warp clock for funding, vesting, staleness windows; test at exact boundaries.
5. **Property/stateful fuzz:** generate random instruction sequences over a small actor set (users, keepers, admin) with random amounts and price moves; assert invariants after each step: conservation of tokens (Σ vault = Σ user claims + fees), no negative equity paths, authority never changes unexpectedly, health monotonic under non-risk actions, no instruction succeeds that should fail by spec.
6. **Differential tests:** compare on-chain fixed-point math with a Python/`mpmath` reference over dense grids and extremes.
7. **Compute regression:** record CU per instruction at worst-case sizes and fail CI on >X% increase.

1. Write invariants and the attacker-account matrix *before* code review ends; each suspected finding becomes a failing test.
2. Run happy + negative suites on every commit (seconds with LiteSVM).
3. Nightly: fuzz with fixed seeds recorded; persist crashing sequences as regression tests.
4. **Mutation check:** break the program deliberately (remove a `has_one`, flip a comparison, remove a signer check); the suite must go red. Unkilled mutants are missing tests.
5. Test with Token-2022 mints and transfer-fee/hook extensions if you accept arbitrary mints (see `spl-token-2022-security`).
6. Test upgrade paths: old-layout account + new program version (migration/versioning).

## Requires

- Rust
- Optional: Anchor
- Optional: LiteSVM or Mollusk

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the solana-testing-fuzzing skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### What does solana-testing-fuzzing do?

LiteSVM/Mollusk/Trident testing for Solana: wrong-account attack matrix, invariants, mutation checks.

### Which AI agents support solana-testing-fuzzing?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use solana-testing-fuzzing?

Connect your AI agent to Agensi through MCP, then ask it to use solana-testing-fuzzing on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
