> ## 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.

# Konfiguracja środowiska

> Metody wzorca Builder do konfigurowania środowisk testowych LiteSVM

Wszystkie metody konfiguracji są metodami typu builder, łączonymi w łańcuch po `LiteSVM::new()`.

<Warning>
  Nie zaczynaj od `LiteSVM::default()`. Tworzy ono pustą instancję bez
  sysvarów, programów i konta airdropu, więc `airdrop` powoduje panikę, a transakcje
  kończą się niepowodzeniem. `LiteSVM::new()` zwraca w pełni skonfigurowaną instancję, którą możesz następnie
  dostosować za pomocą poniższych metod.
</Warning>

## with_compute_budget

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

Ustaw limity jednostek obliczeniowych (compute units) oraz rozmiar sterty.

```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
```

Włącz lub wyłącz weryfikację podpisów. Domyślnie: `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
```

Włącz lub wyłącz walidację blockhash. Domyślnie: `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
```

Ustaw liczbę transakcji przechowywanych w historii. Domyślnie: `32`. Przekazanie `0`
wyłącza historię transakcji, co umożliwia także ponowne wysyłanie zduplikowanych (identycznych)
transakcji.

```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>
  W litesvm 0.18 każda wartość równa 32 lub mniejsza po cichu wyłącza historię, tak samo
  jak `0`: `get_transaction` zwraca `None`, a zduplikowane transakcje są
  akceptowane. Aby zachować historię, użyj wartości większej niż 32, na przykład 100. Wartości
  powyżej 32 powiększają bufor, ale liczba przechowywanych transakcji może się nieznacznie
  różnić od przekazanej wartości.
</Note>

## with_log_bytes_limit

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

Ustaw maksymalną liczbę bajtów dla logów transakcji. Domyślnie: `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
```

Ustaw początkowe saldo konta airdropu (faucet) LiteSVM, z którego finansowane są wywołania
`airdrop`. Domyślnie: `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
```

Dołącz domyślne programy SPL (Token, Associated Token itp.).

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

## with_sysvars

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

Dołącza domyślne sysvary (Clock, Rent, EpochSchedule, SlotHashes, StakeHistory
itp.).

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

## with_feature_set

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

Skonfiguruj zestaw funkcji (feature set) Solany do testowania określonych funkcji środowiska uruchomieniowego.

```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);
```

Najpierw ustaw zestaw funkcji na `LiteSVM::default()`: dodawane po nim wbudowane programy (builtins), sysvary i
konta funkcji będą go uwzględniać. Dołączenie `with_feature_set` do
`LiteSVM::new()` zachowuje sysvar Rent oraz konta funkcji, które `new()` skonfigurowało
dla funkcji mainnetu.

## with_precompiles

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

Dołącza standardowe programy precompile (ed25519, secp256k1, secp256r1). Nie wchodzą
w skład `LiteSVM::new()`, chyba że włączona jest funkcja `precompiles`.

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

<Info>
  Wymaga flagi funkcji `precompiles`:

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

</Info>

## with_feature_accounts

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

Dołącz konta feature gate do środowiska testowego. Dzięki temu
zachowanie środowiska uruchomieniowego Solany zależne od feature gate jest dokładnie odzwierciedlone w Twoich testach.

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

## Funkcja register-tracing

Funkcja `register-tracing` włącza szczegółowe śledzenie rejestrów SBF podczas
wykonywania transakcji. Implikuje ona funkcję `invocation-inspect-callback`.

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

Użyj `LiteSVM::new_debuggable(true)`, aby utworzyć instancję z włączonym śledzeniem
rejestrów:

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

Gdy śledzenie jest włączone, ustaw zmienną środowiskową `SBF_TRACE_DISASSEMBLE`, aby oprócz śladów rejestrów zapisywać również
wynik deasemblacji:

```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)
```

Zarejestruj callback wywoływany przed każdym wywołaniem programu i po nim.
Wymaga funkcji `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);
```
