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

# Memulai

> Instal LiteSVM dan tulis pengujian pertama Anda.

Panduan ini membahas dasar-dasarnya: cara membuat akun, mengisi dana akun, dan
mengirim transaksi.

<Steps titleSize="h2">

<Step title="Instal Dependensi">
<Tabs>
<Tab title="Rust">

Tambahkan LiteSVM ke dev dependencies Anda:

```bash
cargo add --dev litesvm
```

Beberapa crate Solana meningkatkan pengalaman pengujian dengan menyediakan
tipe dan utilitas penting. Contoh di halaman ini menggunakan crate praktis
`solana-sdk` (dipatok ke versi 4.x yang digunakan LiteSVM 0.18) dan crate
antarmuka System Program:

```bash
cargo add --dev solana-sdk@4
cargo add --dev solana-system-interface --features bincode
```

<Warning>
  Gunakan `solana-sdk@4`, bukan versi mayor terbaru. `solana-sdk` yang lebih baru menarik
  salinan kedua dari crate komponen (`solana-keypair`,
  `solana-transaction`, dan lainnya), sehingga tipenya tidak lagi cocok dengan yang
  diharapkan LiteSVM. Jika mau, Anda dapat menambahkan crate komponen individual
  yang di-re-export oleh LiteSVM sebagai pengganti `solana-sdk`.
</Warning>

</Tab>
<Tab title="TypeScript">

```bash
npm install @solana/kit @solana/kit-plugin-litesvm @solana/kit-plugin-signer @solana-program/system
```

</Tab>
</Tabs>

</Step>

<Step title="Buat File Pengujian">
<Tabs>
<Tab title="Rust">

Di dalam workspace Anda, buat folder untuk `tests`.

```bash
mkdir tests
```

</Tab>
<Tab title="TypeScript">

Buat file TypeScript baru untuk pengujian Anda. Pengujian ini menggunakan `await` tingkat atas, jadi
atur `"type": "module"` di `package.json` Anda terlebih dahulu (jika tidak, `tsx` akan gagal dengan
`Top-level await is currently not supported with the "cjs" output format`):

```bash
npm pkg set type=module
touch basic-test.ts
```

</Tab>
</Tabs>

</Step>

<Step title="Buat dan Isi Dana Akun">
<Tabs>
<Tab title="Rust">

Mari tulis pengujian LiteSVM pertama Anda.

Di dalam folder `tests`, buat file baru dan salin kode ini:

```rust tests/create_account.rs
use litesvm::LiteSVM;
use solana_sdk::signature::{Keypair, Signer};

#[test]
fn create_account() {
    // Create the test environment
    let mut svm = LiteSVM::new();

    // Create a test account
    let user = Keypair::new();

    // Fund the account with SOL
    svm.airdrop(&user.pubkey(), 1_000_000_000).unwrap();

    // Check the balance
    let balance = svm.get_balance(&user.pubkey()).unwrap();
    assert_eq!(balance, 1_000_000_000);

    println!("Account funded with {} SOL", balance as f64 / 1e9);
}
```

</Tab>
<Tab title="TypeScript">

Salin kode ini ke file pengujian Anda:

```typescript basic-test.ts
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";
import { litesvm } from "@solana/kit-plugin-litesvm";
import { signer } from "@solana/kit-plugin-signer";

// Payer first, then the LiteSVM transport.
const mySigner = await generateKeyPairSigner();
const client = createClient().use(signer(mySigner)).use(litesvm());

// Fund the payer and check balance
client.svm.airdrop(client.payer.address, lamports(5_000_000_000n));
const balance = client.svm.getBalance(client.payer.address);
console.log("Balance:", balance, "lamports");
```

</Tab>
</Tabs>

</Step>

<Step title="Jalankan Pengujian Anda">
<Tabs>
<Tab title="Rust">

```bash
cargo test create_account -- --show-output
```

Anda akan melihat:

```
running 1 test
test create_account ... ok

successes:

---- create_account stdout ----
Account funded with 1 SOL


successes:
    create_account
```

</Tab>
<Tab title="TypeScript">

```bash
npx tsx basic-test.ts
```

Anda akan melihat:

```
Balance: 5000000000n lamports
```

</Tab>
</Tabs>

<Info>
  Anda baru saja membuat pengujian LiteSVM pertama Anda, yang mencakup pembuatan
  akun dan pengisian dananya.
</Info>

</Step>

<Step title="Jalankan Transaksi">
Sekarang mari kita buat transaksi transfer.

<Tabs>
<Tab title="Rust">

Buat file pengujian baru dan salin kode ini:

```rust tests/transfer_test.rs
use litesvm::LiteSVM;
use solana_sdk::{
    signature::{Keypair, Signer},
    transaction::Transaction,
};
use solana_system_interface::instruction as system_instruction;

#[test]
fn test_transfer() {
    let mut svm = LiteSVM::new();

    // Create two accounts
    let alice = Keypair::new();
    let bob = Keypair::new();

    // Fund Alice
    svm.airdrop(&alice.pubkey(), 2_000_000_000).unwrap();

    // Create transfer instruction
    let transfer = system_instruction::transfer(
        &alice.pubkey(),
        &bob.pubkey(),
        1_000_000_000, // 1 SOL
    );

    // Build and sign transaction
    let tx = Transaction::new_signed_with_payer(
        &[transfer],
        Some(&alice.pubkey()),
        &[&alice],
        svm.latest_blockhash(),
    );

    // Send it (execution happens immediately)
    svm.send_transaction(tx).unwrap();

    // Check new balances
    assert_eq!(svm.get_balance(&bob.pubkey()).unwrap(), 1_000_000_000);
    assert!(svm.get_balance(&alice.pubkey()).unwrap() < 1_000_000_000);

    println!("Transfer successful!");
}
```

</Tab>
<Tab title="TypeScript">

Buat file baru dan salin kode ini:

```typescript transfer-test.ts
import { createClient, generateKeyPairSigner, lamports } from "@solana/kit";
import { litesvm } from "@solana/kit-plugin-litesvm";
import { signer } from "@solana/kit-plugin-signer";
import { systemProgram } from "@solana-program/system";

// Payer first, then the LiteSVM transport, then program plugins.
const mySigner = await generateKeyPairSigner();
const client = createClient()
  .use(signer(mySigner))
  .use(litesvm())
  .use(systemProgram());
const recipient = await generateKeyPairSigner();

// Airdrop SOL to the payer
client.svm.airdrop(client.payer.address, lamports(2_000_000_000n));

// Build and send the transfer
await client.system.instructions
  .transferSol({
    source: client.payer,
    destination: recipient.address,
    amount: lamports(1_000_000_000n) // 1 SOL
  })
  .sendTransaction();

// Check new balances
const recipientBalance = client.svm.getBalance(recipient.address) ?? 0n;
console.log("Recipient balance:", Number(recipientBalance) / 1e9, "SOL");
console.log("Transfer successful!");
```

</Tab>
</Tabs>

<Info>
  Pengujian ini mencakup eksekusi instruksi transfer dari
  System Program.
</Info>

</Step>

<Step title="Jalankan Semua Pengujian">
<Tabs>
<Tab title="Rust">

```bash
cargo test -- --show-output
```

Anda akan melihat:

```
running 1 test
test create_account ... ok

successes:

---- create_account stdout ----
Account funded with 1 SOL


successes:
    create_account

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

     Running tests/transfer_test.rs (target/debug/deps/transfer_test-f174954e7483f36b)

running 1 test
test test_transfer ... ok

successes:

---- test_transfer stdout ----
Transfer successful!


successes:
    test_transfer

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s

   Doc-tests litesvm_quickstart

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```

</Tab>
<Tab title="TypeScript">

```bash
npx tsx basic-test.ts && npx tsx transfer-test.ts
```

Anda akan melihat:

```
Balance: 5000000000n lamports
Recipient balance: 1 SOL
Transfer successful!
```

</Tab>
</Tabs>

<Info>
  Anda kini telah membuat pengujian LiteSVM yang membuat dan mengisi dana akun serta menjalankan transaksi.
</Info>
</Step>

</Steps>

## Langkah Selanjutnya

**[Mengapa LiteSVM →](/developers/docs/tools/litesvm/core-concepts)** Pelajari mengapa Anda perlu
menggunakan LiteSVM untuk pengujian

<Tabs>
  <Tab title="Rust">
    **[Menguji Program Anda →](/developers/docs/tools/litesvm/testing-your-program)** Pelajari
    cara menguji program Solana Anda sendiri <br /> **[Contoh
    →](/developers/docs/tools/litesvm/examples)** Lihat solusi salin-tempel untuk berbagai
    skenario umum dan contoh repositori lengkap <br /> **[Referensi API
    →](/developers/docs/tools/litesvm/api-reference)** Pelajari fitur lanjutan dan konfigurasi
    kustom
  </Tab>
  <Tab title="TypeScript">
    **[Menguji Program Anda →](/developers/docs/tools/litesvm/typescript/getting-started)**
    Pelajari cara menguji program Solana Anda sendiri menggunakan LiteSVM untuk TypeScript{" "}
    <br /> **[Contoh →](/developers/docs/tools/litesvm/typescript/examples)** Lihat
    solusi salin-tempel untuk berbagai skenario umum <br /> **[Referensi API
    →](/developers/docs/tools/litesvm/typescript/api-reference)** Pelajari fitur lanjutan
    dan konfigurasi kustom
  </Tab>
</Tabs>
