모든 구성 메서드는 LiteSVM::default()을 사용한 빌더 패턴을 따릅니다.
with_compute_budget
pub fn with_compute_budget(self, compute_budget: ComputeBudget) -> Self
컴퓨팅 유닛 한도 및 힙 크기를 설정합니다.
use solana_compute_budget::compute_budget::ComputeBudget;let mut svm = LiteSVM::default().with_compute_budget(ComputeBudget {compute_unit_limit: 1_400_000,heap_size: 256 * 1024,..ComputeBudget::default()});
with_sigverify
pub fn with_sigverify(self, sigverify: bool) -> Self
서명 검증을 활성화하거나 비활성화합니다. 기본값: true.
// Disable for faster testslet mut svm = LiteSVM::default().with_sigverify(false);
with_blockhash_check
pub fn with_blockhash_check(self, check: bool) -> Self
블록해시 유효성 검사를 활성화하거나 비활성화합니다. 기본값: true.
// Disable to use any blockhashlet mut svm = LiteSVM::default().with_blockhash_check(false);
with_transaction_history
pub fn with_transaction_history(self, capacity: usize) -> Self
히스토리에 보관할 트랜잭션 수를 설정합니다. 기본값: 0.
// Keep last 100 transactionslet mut svm = LiteSVM::default().with_transaction_history(100);
with_log_bytes_limit
pub fn with_log_bytes_limit(self, limit: Option<usize>) -> Self
트랜잭션 로그의 최대 바이트 수를 설정합니다. 기본값: Some(10_000).
// Unlimited logslet mut svm = LiteSVM::default().with_log_bytes_limit(None);// Custom limit (50KB)let mut svm = LiteSVM::default().with_log_bytes_limit(Some(50_000));
with_lamports
pub fn with_lamports(self, lamports: u64) -> Self
수수료 수집을 위한 초기 lamport를 설정합니다. 기본값: 1_000_000_000.
let mut svm = LiteSVM::default().with_lamports(10_000_000_000);
with_default_programs
pub fn with_default_programs(self) -> Self
기본 SPL 프로그램(Token, Associated Token 등)을 포함합니다.
let mut svm = LiteSVM::default().with_default_programs();
with_sysvars
pub fn with_sysvars(self) -> Self
기본 sysvar(Clock, Rent, EpochSchedule, SlotHashes, StakeHistory 등)를 포함합니다.
let mut svm = LiteSVM::default().with_sysvars();
with_feature_set
pub fn with_feature_set(self, feature_set: FeatureSet) -> Self
특정 런타임 기능 테스트를 위한 Solana 기능 세트를 구성합니다.
use agave_feature_set::FeatureSet;let mut svm = LiteSVM::default().with_feature_set(FeatureSet::all_enabled());
with_precompiles
#[cfg(feature = "precompiles")]pub fn with_precompiles(self) -> Self
표준 사전 컴파일 프로그램(ed25519, secp256k1, secp256r1)을 포함합니다.
let mut svm = LiteSVM::default().with_precompiles();
precompiles 기능 플래그가 필요합니다:
[dev-dependencies]litesvm = { version = "0.11", features = ["precompiles"] }
with_feature_accounts
pub fn with_feature_accounts(self) -> Self
테스트 환경에 기능 게이트 계정을 포함합니다. 이를 통해 기능 게이트된 Solana 런타임 동작이 테스트에 정확하게 반영됩니다.
let mut svm = LiteSVM::default().with_feature_accounts();
register-tracing 기능
register-tracing 기능은 트랜잭션 실행 중 상세한 SBF 레지스터 추적을
활성화합니다. 이 기능은 invocation-inspect-callback 기능을 내포합니다.
[dev-dependencies]litesvm = { version = "0.11", features = ["register-tracing"] }
LiteSVM::new_debuggable(true)를 사용하여 레지스터 추적이 활성화된 인스턴스를
생성합니다:
#[cfg(feature = "register-tracing")]let mut svm = LiteSVM::new_debuggable(true);
활성화된 경우, SBF_TRACE_DISASSEMBLE 환경 변수를 설정하여 레지스터 추적과 함께
디스어셈블리 출력도 덤프할 수 있습니다:
SBF_TRACE_DISASSEMBLE=1 cargo test
set_invocation_inspect_callback
pub fn set_invocation_inspect_callback<C: InvocationInspectCallback + 'static>(&mut self, callback: C)
각 프로그램 호출 전후에 실행되는 콜백을 등록합니다.
invocation-inspect-callback 기능이 필요합니다.
[dev-dependencies]litesvm = { version = "0.11", features = ["invocation-inspect-callback"] }
use litesvm::{LiteSVM, types::InvocationInspectCallback};use solana_svm::invoke_context::InvokeContext;use solana_svm_transaction::svm_message::SVMMessage;struct MyInspector;impl InvocationInspectCallback for MyInspector {fn before_invocation(&self,_svm: &LiteSVM,_tx: &impl SVMMessage,_program_indices: &[u16],_invoke_context: &InvokeContext,) {println!("Before program invocation");}fn after_invocation(&self,_svm: &LiteSVM,_invoke_context: &InvokeContext,_enable_register_tracing: bool,) {println!("After program invocation");}}let mut svm = LiteSVM::new();svm.set_invocation_inspect_callback(MyInspector);
Is this page helpful?