一键导入
substreams-testing
Expert knowledge for testing Solana/SVM Substreams applications. Covers unit testing, integration testing, and performance testing patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Expert knowledge for testing Solana/SVM Substreams applications. Covers unit testing, integration testing, and performance testing patterns.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Expert knowledge for developing Substreams modules on Solana/SVM. Covers manifest spec, Rust modules, IDL-based decoders, protobuf schemas, and Solana-specific data processing patterns.
Naming conventions for tags, releases, and SPKGs in the substreams-svm monorepo. Use when creating releases, tagging versions, or publishing packages.
Instructions for building, packing, and distributing Substreams packages (.spkg) in the substreams-svm monorepo. Use when building crates, running `substreams pack`, or copying .spkg files.
Expert knowledge for consuming Substreams data from Solana/SVM modules. Use when building sinks, real-time data pipelines, or integrating Substreams outputs into applications.
Expert knowledge for building SQL database sinks from Solana/SVM Substreams. Covers DatabaseChanges, ClickHouse schemas, PostgreSQL schemas, and materialized views for Solana DEX/token data.
| name | substreams-testing |
| description | Expert knowledge for testing Solana/SVM Substreams applications. Covers unit testing, integration testing, and performance testing patterns. |
| license | Apache-2.0 |
| compatibility | {"platforms":["claude-code","cursor","vscode","windsurf"]} |
| metadata | {"version":"1.0.0","author":"Pinax Network","documentation":"https://substreams.streamingfast.io"} |
Expert assistant for testing Solana/SVM Substreams applications.
#[cfg(test)]
mod tests {
use super::*;
use substreams_solana_idls::raydium;
#[test]
fn test_unpack_swap_base_in() {
// Known instruction data for a SwapBaseIn
let instruction_data: Vec<u8> = vec![/* raw bytes */];
let result = raydium::amm::v4::instructions::unpack(&instruction_data);
assert!(result.is_ok());
match result.unwrap() {
raydium::amm::v4::instructions::RaydiumV4Instruction::SwapBaseIn(swap) => {
assert!(swap.amount_in > 0);
assert!(swap.minimum_amount_out > 0);
}
_ => panic!("Expected SwapBaseIn instruction"),
}
}
#[test]
fn test_unpack_invalid_data() {
let invalid_data: Vec<u8> = vec![0xFF, 0xFF];
let result = raydium::amm::v4::instructions::unpack(&invalid_data);
assert!(result.is_err());
}
}
#[cfg(test)]
mod tests {
use super::*;
use substreams_solana::base58;
#[test]
fn test_base58_encoding() {
let bytes = vec![0u8; 32];
let encoded = base58::encode(&bytes);
assert_eq!(encoded, "11111111111111111111111111111111");
}
#[test]
fn test_to_global_sequence() {
let clock = Clock {
number: 100,
..Default::default()
};
let seq = to_global_sequence(&clock, 5);
assert_eq!(seq, (100 << 32) + 5);
}
#[test]
fn test_common_key_v2() {
let clock = Clock {
id: "abc123".to_string(),
..Default::default()
};
let keys = common_key_v2(&clock, 0, 1);
assert_eq!(keys[0], ("block_hash", "abc123".to_string()));
assert_eq!(keys[1], ("transaction_index", "0".to_string()));
assert_eq!(keys[2], ("instruction_index", "1".to_string()));
}
}
#[cfg(test)]
mod tests {
use super::*;
use substreams_database_change::tables::Tables;
#[test]
fn test_db_row_creation() {
let mut tables = Tables::new();
tables.create_row("raydium_amm_v4_swap", [
("block_hash", "test_hash".to_string()),
("transaction_index", "0".to_string()),
("instruction_index", "0".to_string()),
])
.set("signature", "test_sig")
.set("fee", 5000u64);
let changes = tables.to_database_changes();
assert_eq!(changes.table_changes.len(), 1);
assert_eq!(changes.table_changes[0].table, "raydium_amm_v4_swap");
}
}
# Test a single DEX module with a small block range
substreams run ./raydium/amm-v4/substreams.yaml \
map_events \
--start-block 250000000 \
--stop-block +100
# Test the aggregate db_out module
substreams run ./db-svm-dex/substreams.yaml \
db_out \
--start-block 250000000 \
--stop-block +100
# Output as JSON for inspection
substreams run ./raydium/amm-v4/substreams.yaml \
map_events \
--start-block 250000000 \
--stop-block +10 \
--output json
# Build all workspace crates
cargo build --target wasm32-unknown-unknown --release
# Run all unit tests (native target)
cargo test
# Build specific crate
cargo build --target wasm32-unknown-unknown --release -p raydium-amm-v4
For ClickHouse sinks with split schema files, verify schemas concatenate correctly:
cd db-svm-dex-clickhouse
make schema # Concatenates split files into schema.sql
| Test Type | Block Range | Purpose |
|---|---|---|
| Smoke test | +10 blocks | Verify basic functionality |
| Unit range | +100 blocks | Check output correctness |
| Integration | +1000 blocks | Verify cross-block consistency |
| Performance | +10000 blocks | Measure throughput |
| Soak test | +100000 blocks | Long-running stability |
blocks_without_votes to exclude ~80% of transactions# Missing wasm target
rustup target add wasm32-unknown-unknown
# Outdated dependencies
cargo update
# Protobuf generation issues
cd proto && make protogen
walk_instructions() covers inner instructions (CPI)is_failed() check if you want to skip them