litesvm_utils/
lib.rs

1//! # litesvm-utils
2//!
3//! General testing utilities for LiteSVM that simplify Solana program testing.
4//!
5//! This crate provides framework-agnostic helpers for:
6//! - Account creation and funding
7//! - Token operations (mints, accounts, minting)
8//! - Transaction execution and result analysis
9//! - Assertion helpers for testing
10//! - PDA derivation
11//!
12//! ## Features
13//!
14//! - **Test Account Helpers**: Create funded accounts, mints, and token accounts in single calls
15//! - **Transaction Helpers**: One-line transaction execution with automatic error handling
16//! - **Assertion Helpers**: Clean, readable test assertions for account states
17//! - **Builder Pattern**: Fluent API for setting up test environments
18//! - **Framework Agnostic**: Works with any Solana program, not just Anchor
19//!
20//! ## Quick Start
21//!
22//! ```ignore
23//! use litesvm_utils::{LiteSVMBuilder, TestHelpers, AssertionHelpers, TransactionHelpers};
24//! use solana_program::pubkey::Pubkey;
25//!
26//! // Initialize with one line!
27//! let program_id = Pubkey::new_unique();
28//! let program_bytes = include_bytes!("../target/deploy/program.so");
29//! let mut svm = LiteSVMBuilder::build_with_program(program_id, program_bytes);
30//!
31//! // Create test accounts in one line each
32//! let maker = svm.create_funded_account(10_000_000_000).unwrap();
33//! let mint = svm.create_token_mint(&maker, 9).unwrap();
34//!
35//! // Send instructions and analyze results
36//! let result = svm.send_instruction(ix, &[&maker]).unwrap();
37//! result.assert_success();
38//!
39//! // Clean assertions
40//! svm.assert_token_balance(&token_account, 100);
41//! svm.assert_sol_balance(&maker.pubkey(), 10_000_000_000);
42//! ```
43
44pub mod assertions;
45pub mod builder;
46pub mod test_helpers;
47pub mod transaction;
48
49// Re-export main types for convenience
50pub use assertions::AssertionHelpers;
51pub use builder::{LiteSVMBuilder, ProgramTestExt};
52pub use test_helpers::TestHelpers;
53pub use transaction::{TransactionError, TransactionHelpers, TransactionResult};
54
55// Re-export commonly used external types
56pub use litesvm::LiteSVM;
57pub use solana_program::pubkey::Pubkey;
58pub use solana_sdk::signature::Keypair;