Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ See [CHANGELOG.md](./CHANGELOG.md) for release history. This file had no changel

- Each example lives at `category/example-name/<framework>/`, e.g. `basics/counter/anchor/`.
- Supported frameworks: `anchor`, `quasar`, `pinocchio`, `native`, `asm`. Use the existing layout as a reference.
- Anchor and Quasar programs usually keep Rust tests under `programs/<name>/tests/`.
- Anchor programs keep Rust tests under `programs/<name>/tests/`.
- Quasar programs keep tests in `src/tests.rs` (inside the single program crate) and run with `cargo test tests::` (per `[testing.rust.test]` in `Quasar.toml`) or `quasar test`.
- Native and Pinocchio tests are Rust + LiteSVM, kept under `program/tests/`.

## Tooling
Expand Down Expand Up @@ -50,7 +51,7 @@ npx tsx --test --test-reporter=spec tests/*.ts

## Documentation

Every `anchor/` (and other framework) directory should include a `README.md`. Use [docs/example-readme-template.md](./docs/example-readme-template.md) as the starting point.
Every `anchor/` (and other framework) directory should include a `README.md`. Use a complete, up-to-date example such as `basics/counter/anchor/README.md` or `finance/escrow/anchor/README.md` as a model.

Also update [CHANGELOG.md](./CHANGELOG.md) when you ship user-visible changes.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Each example is available in one or more of the following frameworks:

## Getting started

You need [Rust](https://www.rust-lang.org/tools/install), [Solana CLI](https://docs.anza.xyz/cli/install), [Anchor](https://www.anchor-lang.com/docs/installation), and [pnpm](https://pnpm.io/installation) installed. Clone the repo and `cd` into any example directory, then run its tests with the command for that framework (shown above) - for an Anchor example, `anchor test`. `pnpm` is used for repo-wide formatting and linting, not for running an example's tests.
You need [Rust](https://www.rust-lang.org/tools/install), [Solana CLI](https://docs.anza.xyz/cli/install), [Anchor](https://www.anchor-lang.com/docs/installation), and [pnpm](https://pnpm.io/installation) installed. Clone the repo and `cd` into any example directory, then run its tests with the command for that framework (shown above) for an Anchor example, `anchor test`. `pnpm` is used for repo-wide formatting and linting, not for running an example's tests.

To deploy to mainnet or devnet you'll need an RPC endpoint. [Quicknode](https://www.quicknode.com/chains/solana) provides free and paid Solana endpoints - create one and set it as your cluster in `Anchor.toml` or with `solana config set --url <your-endpoint>`.
To deploy to mainnet or devnet you'll need an RPC endpoint. [Quicknode](https://www.quicknode.com/chains/solana) provides free and paid Solana endpoints create one and set it as your cluster in `Anchor.toml` or with `solana config set --url <your-endpoint>`.

## Financial software ("DeFi")

Expand Down
7 changes: 5 additions & 2 deletions basics/close-account/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ Two [instruction handlers](https://solana.com/docs/terminology#instruction-handl
## Setup

```bash
pnpm install
anchor build
```

Prerequisites: the [Agave](https://docs.anza.xyz/) toolchain and the [Anchor](https://www.anchor-lang.com/docs) CLI.

## Testing

Tests live in [`programs/close-account/tests/test_close_account.rs`](programs/close-account/tests/test_close_account.rs) and run in-process with LiteSVM:

```bash
pnpm test
anchor test
```

(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.)
9 changes: 6 additions & 3 deletions basics/counter/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ See also: the [repository catalog](../../README.md).
From `basics/counter/anchor/`:

```bash
pnpm install
anchor build
```

Prerequisites: the [Agave](https://docs.anza.xyz/) toolchain and the [Anchor](https://www.anchor-lang.com/docs) CLI.

## Testing

LiteSVM integration tests in `programs/counter_anchor/tests/` call handlers and assert the stored count.

```bash
pnpm test
anchor test
```

LiteSVM integration tests in `programs/counter_anchor/tests/` call handlers and assert the stored count.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.)

## Usage

Expand Down
2 changes: 1 addition & 1 deletion basics/favorites/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ LiteSVM tests in `programs/` assert that users cannot overwrite each other's sta

## Usage

`anchor deploy` targets the cluster in `Anchor.toml`. Used in [Solana Professional Education](https://github.com/solana-developers/professional-education).
`anchor deploy` targets the cluster in `Anchor.toml`.
7 changes: 3 additions & 4 deletions basics/hello-solana/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ See also: [Hello Solana overview](../README.md) and the [repository catalog](../
From this directory (`basics/hello-solana/anchor/`):

```bash
pnpm install
anchor build
```

Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[toolchain]`), [Anchor](https://www.anchor-lang.com/docs), and `pnpm`.
Prerequisites: the [Agave](https://docs.anza.xyz/) toolchain and the [Anchor](https://www.anchor-lang.com/docs) CLI.

## Testing

Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions basics/program-derived-addresses/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions basics/realloc/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions basics/rent/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions basics/transfer-sol/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
2 changes: 0 additions & 2 deletions finance/betting-market/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,3 @@ remove the Bet's entry, and a wallet whose index is full can bet again after clo
```sh
anchor test
```

(`Anchor.toml` sets `test = "cargo test"`, so `cargo test` works too.)
2 changes: 1 addition & 1 deletion finance/lending/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ refreshed in the same transaction, so a typical action transaction is

```sh
anchor build # or: cargo build-sbf — produces target/deploy/lending.so
anchor test # or: cargo test — runs the LiteSVM integration tests
anchor test # runs the LiteSVM integration tests
```

`anchor build` (or `cargo build-sbf`) must run first: the tests load the compiled
Expand Down
4 changes: 2 additions & 2 deletions finance/token-swap/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions tokens/create-token/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
4 changes: 2 additions & 2 deletions tokens/transfer-tokens/anchor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Prerequisites: [Agave](https://docs.anza.xyz/) CLI (version in `Anchor.toml` `[t
Tests run in-process with [LiteSVM](https://www.anchor-lang.com/docs/testing/litesvm). No local validator.

```bash
pnpm test
anchor test
```

This runs `cargo test` as configured in `Anchor.toml`. Tests call instruction handlers and check onchain state.
(`anchor test` runs the command configured in `Anchor.toml` `[scripts] test`.) Tests call instruction handlers and check onchain state.

## Usage

Expand Down
Loading