Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LiteSVM/litesvm
https://github.com/LiteSVM/litesvm
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/LiteSVM/litesvm
- Owner: LiteSVM
- License: apache-2.0
- Created: 2023-11-18T11:02:30.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-07-26T10:20:33.000Z (4 months ago)
- Last Synced: 2024-08-11T09:20:47.108Z (3 months ago)
- Language: Rust
- Size: 1010 KB
- Stars: 59
- Watchers: 3
- Forks: 12
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- solana-awesome - Link - process Solana VM optimized for program developers | (Developer Resources / Testing Programs)
- awesome - LiteSVM/litesvm - (Rust)
README
---
# LiteSVM
[](https://github.com/LiteSVM/litesvm)
[](https://crates.io/crates/litesvm)
[](https://docs.rs/litesvm/latest/litesvm/)
[](https://github.com/LiteSVM/litesvm/actions?query=branch%3Amaster)## 📍 Overview
`litesvm` is a fast and lightweight library for testing Solana programs. It works by creating an in-process Solana VM optimized for program developers. This makes it much faster to run and compile than alternatives like `solana-program-test` and `solana-test-validator`. In a further break from tradition, it has an ergonomic API with sane defaults and extensive configurability for those who want it.
## 🚀 Getting Started
### 🔧 Installation
```sh
cargo add --dev litesvm
```### 🤖 Minimal Example
```rust
use litesvm::LiteSVM;
use solana_program::{message::Message, pubkey::Pubkey, system_instruction::transfer};
use solana_sdk::{signature::Keypair, signer::Signer, transaction::Transaction};let from_keypair = Keypair::new();
let from = from_keypair.pubkey();
let to = Pubkey::new_unique();let mut svm = LiteSVM::new();
svm.airdrop(&from, 10_000).unwrap();let instruction = transfer(&from, &to, 64);
let tx = Transaction::new(
&[&from_keypair],
Message::new(&[instruction], Some(&from)),
svm.latest_blockhash(),
);
let tx_res = svm.send_transaction(tx).unwrap();let from_account = svm.get_account(&from);
let to_account = svm.get_account(&to);
assert_eq!(from_account.unwrap().lamports, 4936);
assert_eq!(to_account.unwrap().lamports, 64);
```### Developing litesvm
#### Run the tests
The tests in this repo use some test programs you need to build first (Solana CLI >= 1.18.8 required):
```cd test_programs && cargo build-sbf```
Then just run `cargo test`.