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

# Δοκιμές προγραμμάτων

> Φόρτωση και δοκιμή προσαρμοσμένων προγραμμάτων Solana με το LiteSVM

Η δοκιμή ενός προσαρμοσμένου προγράμματος Solana σημαίνει φόρτωση του μεταγλωττισμένου αρχείου `.so` στο
SVM, ρύθμιση των λογαριασμών που αναμένει και αποστολή εντολών προς αυτό.
Το LiteSVM τα χειρίζεται όλα αυτά in-process — χωρίς να χρειάζεται validator. Συνιστούμε
τη δημιουργία πελατών προγράμματος (program clients) με το
[Codama JS Renderer](https://github.com/codama-idl/renderers-js), ώστε να έχετε
πρόσβαση σε ένα συμβατό Kit Plugin.

## Φόρτωση ενός προγράμματος

<Note>
  Η εισαγωγή `@my-program/sdk` είναι ένα placeholder για έναν client που έχει δημιουργηθεί με το Codama
  για το δικό σας πρόγραμμα. Τα δύο αυτά παραδείγματα είναι ενδεικτικά πρότυπα: αντικαταστήστε
  τα ονόματα του plugin, της εντολής και του λογαριασμού με τα δικά σας πριν τα εκτελέσετε.
</Note>

```typescript
import { createClient, address, generateKeyPairSigner } from "@solana/kit";
import { litesvm } from "@solana/kit-plugin-litesvm";
import { signer } from "@solana/kit-plugin-signer";
import { myProgramPlugin } from "@my-program/sdk";
import * as fs from "node:fs";

const mySigner = await generateKeyPairSigner();
const client = createClient()
  .use(signer(mySigner))
  .use(litesvm())
  .use(myProgramPlugin());

// Configure for program testing
client.svm
  .withSigverify(false)
  .withBlockhashCheck(false)
  .withSysvars()
  .withBuiltins();

// Load program from .so file
const programId = (await generateKeyPairSigner()).address;
const soPath = "/path/to/target/deploy/my_program.so";

if (fs.existsSync(soPath)) {
  client.svm.addProgramFromFile(programId, soPath);
  console.log("Program loaded:", programId);

  // Verify program account
  const programAccount = client.svm.getAccount(programId);
  if (programAccount.exists) {
    console.log("  Executable:", programAccount.executable);
    console.log("  Data size:", programAccount.data.length, "bytes");
  }
} else {
  console.log("Program file not found:", soPath);
  console.log("Build with: cargo build-sbf");
}
```

## Πλήρης ρύθμιση δοκιμής προγράμματος

<Note>
  Ενδεικτικό πρότυπο: τα `myProgramPlugin`, `testInstruction` και `myAccount`
  προέρχονται από τον δικό σας παραγόμενο client.
</Note>

```typescript
import { createClient, address, generateKeyPairSigner, lamports } from '@solana/kit';
import { litesvm } from '@solana/kit-plugin-litesvm';
import { signer } from '@solana/kit-plugin-signer';
import { myProgramPlugin } from '@my-program/sdk';
import * as fs from 'node:fs';

const mySigner = await generateKeyPairSigner();
const client = createClient()
    .use(signer(mySigner))
    .use(litesvm())
    .use(myProgramPlugin());

client.svm
    .withSigverify(false)
    .withBlockhashCheck(false)
    .withSysvars()
    .withBuiltins()
    .withPrecompiles()
    .withTransactionHistory(100n);

// Load program
const programId = (await generateKeyPairSigner()).address;
const soPath = '/path/to/target/deploy/my_program.so';

if (fs.existsSync(soPath)) {
    client.svm.addProgramFromFile(programId, soPath);
}

// Set up any required data accounts
const dataAccountAddress = (await generateKeyPairSigner()).address;
const minBalance = client.svm.minimumBalanceForRentExemption(100n);
client.svm.setAccount({
    address: dataAccountAddress,
    data: new Uint8Array(100),
    executable: false,
    lamports: lamports(minBalance),
    programAddress: programId,
    space: 100n,
});

// Send the transaction
await client.myProgram.testInstruction({ /* args */ }).sendTransaction();

// Verify state changes
const updatedAccount = client.myProgram.myAccount.fetch(dataAccountAddress);
// assert on decoded account
```

## Χρήση των προεπιλεγμένων προγραμμάτων

Ένας client `litesvm()` έχει ήδη φορτωμένα τα βασικά προγράμματα: το System
Program, τους BPF loaders, τα Vote, Compute Budget, Stake, Address Lookup Table,
Token, Token-2022, Associated Token Account, Memo, και τα precompiles ed25519, secp256k1
και secp256r1. Φορτώστε μόνο τα υπόλοιπα προγράμματα που καλεί η δοκιμή σας:

```typescript
const mySigner = await generateKeyPairSigner();
const client = createClient().use(signer(mySigner)).use(litesvm());

// Token, Token-2022, Associated Token Account and Memo are already loaded.
// Add any other program your program calls from its .so file
client.svm.addProgramFromFile(otherProgramId, "/path/to/other_program.so");
```

<Info>
  Μεταγλωττίστε το πρόγραμμα Solana με `cargo build-sbf` για να δημιουργήσετε το αρχείο `.so`.
</Info>

Το μοτίβο είναι πάντα το ίδιο:

1. **Φόρτωση προγράμματος**: Χρησιμοποιήστε το `addProgramFromFile` για να φορτώσετε μεταγλωττισμένα προγράμματα και
   εισαγάγετε το myProgramPlugin() από τον client σας
2. **Διαμόρφωση**: Αλλάξτε ρυθμίσεις, όπως η επαλήθευση υπογραφών, αν
   χρειάζεται· τα sysvars, τα builtins, τα precompiles και τα προεπιλεγμένα προγράμματα είναι ήδη
   φορτωμένα
3. **Ρύθμιση λογαριασμών**: Συμπληρώστε εκ των προτέρων τους λογαριασμούς δεδομένων με το `setAccount`
4. **Αποστολή**: Χρησιμοποιήστε `client.myProgram.testInstruction({ /* args */ }).sendTransaction()` —
   χωρίς χειροκίνητη κατασκευή συναλλαγής
5. **Επαλήθευση**: Ελέγξτε την κατάσταση του λογαριασμού μετά την εκτέλεση
   (`client.myProgram.myAccount.fetch`)

Όταν αυτό το πρότυπο λειτουργήσει, μπορείτε να δημιουργήσετε μια πλήρη σουίτα δοκιμών
προσθέτοντας περισσότερες εντολές και assertions.
