Ortam Yapılandırması

Tüm yapılandırma yöntemleri, LiteSVM::default() ile builder pattern kullanır.

with_compute_budget

pub fn with_compute_budget(self, compute_budget: ComputeBudget) -> Self

Hesaplama birimi limitlerini ve heap boyutunu ayarlayın.

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

İmza doğrulamasını etkinleştirin veya devre dışı bırakın. Varsayılan: true.

// Disable for faster tests
let mut svm = LiteSVM::default()
.with_sigverify(false);

with_blockhash_check

pub fn with_blockhash_check(self, check: bool) -> Self

Blockhash doğrulamasını etkinleştirin veya devre dışı bırakın. Varsayılan: true.

// Disable to use any blockhash
let mut svm = LiteSVM::default()
.with_blockhash_check(false);

with_transaction_history

pub fn with_transaction_history(self, capacity: usize) -> Self

Geçmişte tutulacak işlem sayısını ayarlayın. Varsayılan: 0.

// Keep last 100 transactions
let mut svm = LiteSVM::default()
.with_transaction_history(100);

with_log_bytes_limit

pub fn with_log_bytes_limit(self, limit: Option<usize>) -> Self

İşlem günlükleri için maksimum bayt sayısını ayarlayın. Varsayılan: Some(10_000).

// Unlimited logs
let 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

Ücret tahsilatı için başlangıç lamport değerini ayarlayın. Varsayılan: 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

Varsayılan SPL programlarını dahil edin (Token, Associated Token, vb.).

let mut svm = LiteSVM::default()
.with_default_programs();

with_sysvars

pub fn with_sysvars(self) -> Self

Varsayılan sysvar'ları dahil eder (Clock, Rent, EpochSchedule, SlotHashes, StakeHistory, vb.).

let mut svm = LiteSVM::default()
.with_sysvars();

with_feature_set

pub fn with_feature_set(self, feature_set: FeatureSet) -> Self

Belirli çalışma zamanı özelliklerini test etmek için Solana özellik setini yapılandırın.

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

Standart ön derleme programlarını dahil eder (ed25519, secp256k1, secp256r1).

let mut svm = LiteSVM::default()
.with_precompiles();

precompiles özellik bayrağını gerektirir:

[dev-dependencies]
litesvm = { version = "0.11", features = ["precompiles"] }

with_feature_accounts

pub fn with_feature_accounts(self) -> Self

Test ortamına özellik kapısı hesaplarını dahil edin. Bu, özellik kapılı Solana çalışma zamanı davranışının testlerinizde doğru şekilde yansıtılmasını sağlar.

let mut svm = LiteSVM::default()
.with_feature_accounts();

register-tracing özelliği

register-tracing özelliği, işlem yürütme sırasında ayrıntılı SBF yazmaç izlemeyi etkinleştirir. invocation-inspect-callback özelliğini de kapsar.

[dev-dependencies]
litesvm = { version = "0.11", features = ["register-tracing"] }

Yazmaç izleme etkinleştirilmiş bir örnek oluşturmak için LiteSVM::new_debuggable(true) kullanın:

#[cfg(feature = "register-tracing")]
let mut svm = LiteSVM::new_debuggable(true);

Etkinleştirildiğinde, yazmaç izleriyle birlikte ayrıştırma çıktısını da dökmek için SBF_TRACE_DISASSEMBLE ortam değişkenini ayarlayın:

SBF_TRACE_DISASSEMBLE=1 cargo test

set_invocation_inspect_callback

pub fn set_invocation_inspect_callback<C: InvocationInspectCallback + 'static>(&mut self, callback: C)

Her program çağrısından önce ve sonra tetiklenen bir geri çağırma işlevi kaydedin. invocation-inspect-callback özelliğini gerektirir.

[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?

İçindekiler

Sayfayı Düzenle
© 2026 Solana Vakfı. Tüm hakları saklıdır.