> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Konfigurasi Lingkungan

> Metode pola builder untuk mengonfigurasi lingkungan pengujian LiteSVM

Semua metode konfigurasi adalah metode builder yang dirangkai pada `LiteSVM::new()`.

<Warning>
  Jangan memulai dari `LiteSVM::default()`. Fungsi ini membuat instance kosong
  tanpa sysvar, program, atau akun airdrop, sehingga `airdrop` mengalami panic
  dan transaksi gagal. `LiteSVM::new()` mengembalikan instance yang sudah
  disiapkan sepenuhnya, yang kemudian dapat Anda sesuaikan dengan metode di
  bawah ini.
</Warning>

## with_compute_budget

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

Menetapkan batas compute unit dan ukuran heap.

```rust
use solana_compute_budget::compute_budget::ComputeBudget;

let mut svm = LiteSVM::new()
    .with_compute_budget(ComputeBudget {
        compute_unit_limit: 1_400_000,
        heap_size: 256 * 1024,
        ..ComputeBudget::new_with_defaults(true)
    });
```

## with_sigverify

```rust
pub fn with_sigverify(self, sigverify: bool) -> Self
```

Mengaktifkan atau menonaktifkan verifikasi tanda tangan. Default: `true`.

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

## with_blockhash_check

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

Mengaktifkan atau menonaktifkan validasi blockhash. Default: `true`.

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

## with_transaction_history

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

Menetapkan jumlah transaksi yang disimpan dalam riwayat. Default: `32`. Jika
diisi `0`, riwayat transaksi dinonaktifkan, yang juga memungkinkan transaksi
duplikat (identik) dikirim ulang.

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

// Disable history and allow duplicate transactions
let mut svm = LiteSVM::new()
    .with_transaction_history(0);
```

<Note>
  Pada litesvm 0.18, nilai 32 atau kurang secara diam-diam menonaktifkan
  riwayat, sama seperti `0`: `get_transaction` mengembalikan `None` dan
  transaksi duplikat diterima. Untuk mempertahankan riwayat, gunakan nilai
  lebih dari 32, misalnya 100. Nilai di atas 32 memperbesar buffer, tetapi
  jumlah transaksi yang disimpan dapat sedikit berbeda dari nilai yang Anda
  berikan.
</Note>

## with_log_bytes_limit

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

Menetapkan jumlah byte maksimum untuk log transaksi. Default: `Some(10_000)`.

```rust
// Unlimited logs
let mut svm = LiteSVM::new()
    .with_log_bytes_limit(None);

// Custom limit (50KB)
let mut svm = LiteSVM::new()
    .with_log_bytes_limit(Some(50_000));
```

## with_lamports

```rust
pub fn with_lamports(self, lamports: u64) -> Self
```

Menetapkan saldo awal akun airdrop (faucet) LiteSVM, yang mendanai panggilan
`airdrop`. Default: `1_000_000_000_000_000` (1e15 lamports).

```rust
let mut svm = LiteSVM::new()
    .with_lamports(10_000_000_000);
```

## with_default_programs

```rust
pub fn with_default_programs(self) -> Self
```

Menyertakan program SPL default (Token, Associated Token, dll.).

```rust
let mut svm = LiteSVM::new()
    .with_default_programs();
```

## with_sysvars

```rust
pub fn with_sysvars(self) -> Self
```

Menyertakan sysvar default (Clock, Rent, EpochSchedule, SlotHashes,
StakeHistory, dll.).

```rust
let mut svm = LiteSVM::new()
    .with_sysvars();
```

## with_feature_set

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

Mengonfigurasi feature set Solana untuk menguji fitur runtime tertentu.

```rust
use agave_feature_set::FeatureSet;
use solana_sdk::native_token::LAMPORTS_PER_SOL;

let mut svm = LiteSVM::default()
    .with_feature_set(FeatureSet::all_enabled())
    .with_builtins()
    .with_lamports(1_000_000 * LAMPORTS_PER_SOL)
    .with_sysvars()
    .with_feature_accounts()
    .with_default_programs()
    .with_sigverify(true)
    .with_blockhash_check(true);
```

Tetapkan feature set terlebih dahulu, pada `LiteSVM::default()`: builtin, sysvar,
dan akun fitur yang ditambahkan setelahnya mengikuti feature set tersebut.
Merangkai `with_feature_set` pada `LiteSVM::new()` mempertahankan sysvar Rent
dan akun fitur yang disiapkan oleh `new()` untuk fitur mainnet.

## with_precompiles

```rust
#[cfg(feature = "precompiles")]
pub fn with_precompiles(self) -> Self
```

Menyertakan program precompile standar (ed25519, secp256k1, secp256r1). Program
ini bukan bagian dari `LiteSVM::new()` kecuali fitur `precompiles` diaktifkan.

```rust
let mut svm = LiteSVM::new()
    .with_precompiles();
```

<Info>
  Memerlukan feature flag `precompiles`:

```toml
[dev-dependencies]
litesvm = { version = "0.18", features = ["precompiles"] }
```

</Info>

## with_feature_accounts

```rust
pub fn with_feature_accounts(self) -> Self
```

Menyertakan akun feature gate dalam lingkungan pengujian. Ini memastikan
perilaku runtime Solana yang dikontrol feature gate tercermin secara akurat
dalam pengujian Anda.

```rust
let mut svm = LiteSVM::new()
    .with_feature_accounts();
```

## Fitur register-tracing

Fitur `register-tracing` mengaktifkan pelacakan register SBF yang mendetail
selama eksekusi transaksi. Fitur ini mengimplikasikan fitur
`invocation-inspect-callback`.

```toml
[dev-dependencies]
litesvm = { version = "0.18", features = ["register-tracing"] }
```

Gunakan `LiteSVM::new_debuggable(true)` untuk membuat instance dengan pelacakan
register yang diaktifkan:

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

Saat diaktifkan, tetapkan variabel lingkungan `SBF_TRACE_DISASSEMBLE` untuk
juga mengeluarkan output disassembly bersama jejak register:

```bash
SBF_TRACE_DISASSEMBLE=1 cargo test
```

## set_invocation_inspect_callback

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

Mendaftarkan callback yang dipicu sebelum dan sesudah setiap pemanggilan
program. Memerlukan fitur `invocation-inspect-callback`.

```toml
[dev-dependencies]
litesvm = { version = "0.18", features = ["invocation-inspect-callback"] }
solana-program-runtime = "4"
solana-transaction = "4"
```

```rust
use litesvm::{InvocationInspectCallback, LiteSVM};
use solana_program_runtime::invoke_context::InvokeContext;
use solana_transaction::sanitized::SanitizedTransaction;

struct MyInspector;

impl InvocationInspectCallback for MyInspector {
    fn before_invocation(
        &self,
        _svm: &LiteSVM,
        _tx: &SanitizedTransaction,
        _program_indices: &[u16],
        _invoke_context: &mut InvokeContext,
        _enable_register_tracing: bool,
    ) {
        println!("Before program invocation");
    }

    fn after_invocation(
        &self,
        _svm: &LiteSVM,
        _tx: &SanitizedTransaction,
        _program_indices: &[u16],
        _invoke_context: &InvokeContext,
        _enable_register_tracing: bool,
    ) {
        println!("After program invocation");
    }
}

let mut svm = LiteSVM::new();
svm.set_invocation_inspect_callback(MyInspector);
```
