From f8dbbc266c97a28dcfe78586838ce8aae78223be Mon Sep 17 00:00:00 2001 From: Mike MacCana Date: Thu, 2 Jul 2026 14:00:41 -0400 Subject: [PATCH] docs: recommend single command 'anchor test' for Anchor examples; clean legacy references - Standardize Anchor testing instructions on one command: `anchor test`. - Remove alternative `cargo test` suggestions from CONTRIBUTING.md and Anchor READMEs (counter, hello-solana, close-account, transfer-sol, rent, realloc, token-swap, transfer-tokens, create-token, program-derived-addresses, etc.). - Update root README framework description and getting-started text for consistency. - Remove ACTIVE-AUDIT-ITEMS.md from this PR (per request). - Preserve contributor credits in Pinocchio examples (e.g. @MarkFeder ports from solana-developers/program-examples) while cleaning other stale references. Co-authored-by: Cursor --- CONTRIBUTING.md | 5 +++-- README.md | 4 ++-- basics/close-account/anchor/README.md | 7 +++++-- basics/counter/anchor/README.md | 9 ++++++--- basics/favorites/anchor/README.md | 2 +- basics/hello-solana/anchor/README.md | 7 +++---- basics/program-derived-addresses/anchor/README.md | 4 ++-- basics/realloc/anchor/README.md | 4 ++-- basics/rent/anchor/README.md | 4 ++-- basics/transfer-sol/anchor/README.md | 4 ++-- finance/betting-market/anchor/README.md | 2 -- finance/lending/anchor/README.md | 2 +- finance/token-swap/anchor/README.md | 4 ++-- tokens/create-token/anchor/README.md | 4 ++-- tokens/transfer-tokens/anchor/README.md | 4 ++-- 15 files changed, 35 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d2096449..6b043152 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,8 @@ See [CHANGELOG.md](./CHANGELOG.md) for release history. This file had no changel - Each example lives at `category/example-name//`, 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//tests/`. +- Anchor programs keep Rust tests under `programs//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 @@ -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. diff --git a/README.md b/README.md index 02f94fa4..8ab6b6ae 100644 --- a/README.md +++ b/README.md @@ -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 `. +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 `. ## Financial software ("DeFi") diff --git a/basics/close-account/anchor/README.md b/basics/close-account/anchor/README.md index b1d7c770..5efc0fcd 100644 --- a/basics/close-account/anchor/README.md +++ b/basics/close-account/anchor/README.md @@ -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`.) diff --git a/basics/counter/anchor/README.md b/basics/counter/anchor/README.md index 778ed7d9..1e5fddb8 100644 --- a/basics/counter/anchor/README.md +++ b/basics/counter/anchor/README.md @@ -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 diff --git a/basics/favorites/anchor/README.md b/basics/favorites/anchor/README.md index fb2cac1c..0de26cf3 100644 --- a/basics/favorites/anchor/README.md +++ b/basics/favorites/anchor/README.md @@ -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). \ No newline at end of file +`anchor deploy` targets the cluster in `Anchor.toml`. \ No newline at end of file diff --git a/basics/hello-solana/anchor/README.md b/basics/hello-solana/anchor/README.md index 3c77bc30..1c45f86c 100644 --- a/basics/hello-solana/anchor/README.md +++ b/basics/hello-solana/anchor/README.md @@ -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 diff --git a/basics/program-derived-addresses/anchor/README.md b/basics/program-derived-addresses/anchor/README.md index 01d33b07..7307fbc8 100644 --- a/basics/program-derived-addresses/anchor/README.md +++ b/basics/program-derived-addresses/anchor/README.md @@ -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 diff --git a/basics/realloc/anchor/README.md b/basics/realloc/anchor/README.md index 613be789..abb45aa4 100644 --- a/basics/realloc/anchor/README.md +++ b/basics/realloc/anchor/README.md @@ -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 diff --git a/basics/rent/anchor/README.md b/basics/rent/anchor/README.md index 5215a52a..b1325601 100644 --- a/basics/rent/anchor/README.md +++ b/basics/rent/anchor/README.md @@ -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 diff --git a/basics/transfer-sol/anchor/README.md b/basics/transfer-sol/anchor/README.md index 92a37c3c..d94a931e 100644 --- a/basics/transfer-sol/anchor/README.md +++ b/basics/transfer-sol/anchor/README.md @@ -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 diff --git a/finance/betting-market/anchor/README.md b/finance/betting-market/anchor/README.md index 9337779b..63227ade 100644 --- a/finance/betting-market/anchor/README.md +++ b/finance/betting-market/anchor/README.md @@ -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.) diff --git a/finance/lending/anchor/README.md b/finance/lending/anchor/README.md index 3bc967cc..4fc0817f 100644 --- a/finance/lending/anchor/README.md +++ b/finance/lending/anchor/README.md @@ -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 diff --git a/finance/token-swap/anchor/README.md b/finance/token-swap/anchor/README.md index 11b48c16..99769e05 100644 --- a/finance/token-swap/anchor/README.md +++ b/finance/token-swap/anchor/README.md @@ -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 diff --git a/tokens/create-token/anchor/README.md b/tokens/create-token/anchor/README.md index f63c34d8..b20d1f53 100644 --- a/tokens/create-token/anchor/README.md +++ b/tokens/create-token/anchor/README.md @@ -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 diff --git a/tokens/transfer-tokens/anchor/README.md b/tokens/transfer-tokens/anchor/README.md index b173325e..d27abda6 100644 --- a/tokens/transfer-tokens/anchor/README.md +++ b/tokens/transfer-tokens/anchor/README.md @@ -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