From 80cfb95fedf6537d5bb56c076002a40be23b6a2f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 15:35:46 +0000 Subject: [PATCH 1/4] test: move every example onto Anchor v2's LiteSVM harness Anchor v2 ships its own LiteSVM wrapper, `anchor-v2-testing`. Tests that call `LiteSVM::new()` directly still run and still pass, but they record nothing, so `anchor test --profile`, `anchor debugger` and `anchor coverage` all come back empty. Going through `anchor_v2_testing::svm()` is what connects a test to those three tools; it is `LiteSVM::new()` until the `profile` feature turns tracing on, so the default path costs nothing. Per program crate, the dev-dependencies drop `litesvm`, `solana-signer` and `solana-keypair`, which the harness re-exports, and gain the harness plus a `profile` feature forwarding to it. Tests swap `LiteSVM::new()` for `anchor_v2_testing::svm()` and their imports follow. The execution model does not change: same in-process LiteSVM, same solana-kite helpers, which take the same `LiteSVM` value. The harness is published only from git; crates.io has no `anchor-v2-testing`, and a git dependency is what the v2 testing documentation prescribes. It is pinned to a revision rather than tracking `anchor-next`: Cargo.lock is not tracked in this repository, so CI resolves fresh on every run, and a branch would let an upstream push change a build with no commit here to explain it. Bumping the rev is then a deliberate, reviewable change. Two things stay as they were. The one test using `solana_transaction::Transaction` keeps that dependency, because the harness re-exports `VersionedTransaction` and not `Transaction`. `mock-swap-router` has no tests, so it gains nothing. Verified locally before the full sweep: `basics/counter` passes its 3 tests and `anchor coverage` resolves 294 of 312 program counters to source across 19 files; `finance/lending`, eight test binaries over a shared harness, passes all 26. --- .../programs/anchor-program-example/Cargo.toml | 15 ++++++++++++--- .../tests/test_account_data.rs | 6 ++---- .../programs/anchor-program-example/Cargo.toml | 15 ++++++++++++--- .../tests/test_checking_accounts.rs | 6 ++---- .../anchor/programs/close-account/Cargo.toml | 15 ++++++++++++--- .../close-account/tests/test_close_account.rs | 6 ++---- .../anchor/programs/counter_anchor/Cargo.toml | 15 ++++++++++++--- .../programs/counter_anchor/tests/test_counter.rs | 6 ++---- .../programs/create-system-account/Cargo.toml | 15 ++++++++++++--- .../tests/test_create_account.rs | 6 ++---- .../anchor/programs/hand/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/hand/tests/test_hand.rs | 6 ++---- .../anchor/programs/lever/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/lever/tests/test_lever.rs | 8 +++----- .../anchor/programs/favorites/Cargo.toml | 15 ++++++++++++--- .../programs/favorites/tests/test_favorites.rs | 5 ++--- .../anchor/programs/hello-solana/Cargo.toml | 14 ++++++++++++-- .../programs/hello-solana/tests/test_hello.rs | 5 ++--- .../programs/anchor-program-example/Cargo.toml | 15 ++++++++++++--- .../tests/test_pda_rent_payer.rs | 6 ++---- .../programs/processing-instructions/Cargo.toml | 15 ++++++++++++--- .../tests/test_processing_instructions.rs | 5 ++--- .../programs/anchor-program-example/Cargo.toml | 15 ++++++++++++--- .../tests/test_program_derived_addresses.rs | 5 ++--- .../pyth/anchor/programs/pythexample/Cargo.toml | 15 ++++++++++++--- .../programs/pythexample/tests/test_pyth.rs | 6 ++---- .../anchor/programs/anchor-realloc/Cargo.toml | 15 ++++++++++++--- .../programs/anchor-realloc/tests/test_realloc.rs | 10 ++++------ .../rent/anchor/programs/rent-example/Cargo.toml | 15 ++++++++++++--- .../programs/rent-example/tests/test_rent.rs | 6 ++---- .../anchor/programs/carnival/Cargo.toml | 15 ++++++++++++--- .../programs/carnival/tests/test_carnival.rs | 5 ++--- .../anchor/programs/transfer-sol/Cargo.toml | 15 ++++++++++++--- .../transfer-sol/tests/test_transfer_sol.rs | 10 ++++------ .../anchor/programs/cnft-burn/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/cnft-burn/tests/test_burn.rs | 6 ++---- .../anchor/programs/cnft-vault/Cargo.toml | 15 ++++++++++++--- .../programs/cnft-vault/tests/test_vault.rs | 6 ++---- .../cutils/anchor/programs/cutils/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/cutils/tests/test_cutils.rs | 6 ++---- .../anchor/programs/betting-market/Cargo.toml | 15 ++++++++++++--- .../betting-market/tests/test_betting_market.rs | 6 ++---- finance/escrow/anchor/programs/escrow/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/escrow/tests/test_escrow.rs | 6 ++---- .../lending/anchor/programs/lending/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/lending/tests/common/mod.rs | 6 ++---- .../programs/lending/tests/test_borrow_repay.rs | 3 +-- .../programs/lending/tests/test_interest.rs | 2 +- .../programs/lending/tests/test_liquidation.rs | 3 +-- .../programs/lending/tests/test_rounding.rs | 2 +- .../programs/lending/tests/test_security.rs | 2 +- .../anchor/programs/order-book/Cargo.toml | 15 ++++++++++++--- .../programs/order-book/tests/test_order_book.rs | 6 ++---- .../anchor/programs/perpetual-futures/Cargo.toml | 15 ++++++++++++--- .../tests/test_perpetual_futures.rs | 6 ++---- .../prop-amm/anchor/programs/prop-amm/Cargo.toml | 15 ++++++++++++--- .../programs/prop-amm/tests/test_prop_amm.rs | 6 ++---- .../anchor/programs/fundraiser/Cargo.toml | 15 ++++++++++++--- .../programs/fundraiser/tests/test_fundraiser.rs | 6 ++---- .../anchor/programs/token-swap/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/token-swap/tests/test_swap.rs | 6 ++---- .../anchor/programs/vault-strategy/Cargo.toml | 15 ++++++++++++--- .../vault-strategy/tests/vault_strategy.rs | 6 ++---- .../anchor/programs/create-token/Cargo.toml | 15 ++++++++++++--- .../create-token/tests/test_create_token.rs | 6 ++---- .../external-delegate-token-master/Cargo.toml | 15 ++++++++++++--- .../tests/test_external_delegate.rs | 6 ++---- .../anchor/programs/nft-minter/Cargo.toml | 15 ++++++++++++--- .../programs/nft-minter/tests/test_nft_minter.rs | 6 ++---- .../anchor/programs/mint-nft/Cargo.toml | 15 ++++++++++++--- .../mint-nft/tests/test_nft_operations.rs | 6 ++---- .../anchor/programs/token-minter/Cargo.toml | 15 ++++++++++++--- .../programs/token-minter/tests/test_pda_mint.rs | 6 ++---- .../basics/anchor/programs/basics/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/basics/tests/test_basics.rs | 6 ++---- .../anchor/programs/cpi-guard/Cargo.toml | 15 ++++++++++++--- .../programs/cpi-guard/tests/test_cpi_guard.rs | 6 ++---- .../programs/default-account-state/Cargo.toml | 15 ++++++++++++--- .../tests/test_default_account_state.rs | 6 ++---- .../group/anchor/programs/group/Cargo.toml | 15 ++++++++++++--- .../anchor/programs/group/tests/test_group.rs | 5 ++--- .../anchor/programs/immutable-owner/Cargo.toml | 15 ++++++++++++--- .../immutable-owner/tests/test_immutable_owner.rs | 6 ++---- .../anchor/programs/interest-bearing/Cargo.toml | 15 ++++++++++++--- .../tests/test_interest_bearing.rs | 6 ++---- .../anchor/programs/memo-transfer/Cargo.toml | 15 ++++++++++++--- .../memo-transfer/tests/test_memo_transfer.rs | 6 ++---- .../metadata/anchor/programs/metadata/Cargo.toml | 15 ++++++++++++--- .../programs/metadata/tests/test_metadata.rs | 6 ++---- .../programs/mint-close-authority/Cargo.toml | 15 ++++++++++++--- .../tests/test_mint_close_authority.rs | 6 ++---- .../anchor/programs/extension_nft/Cargo.toml | 15 ++++++++++++--- .../extension_nft/tests/test_extension_nft.rs | 6 ++---- .../anchor/programs/non-transferable/Cargo.toml | 15 ++++++++++++--- .../tests/test_non_transferable.rs | 6 ++---- .../anchor/programs/permanent-delegate/Cargo.toml | 15 ++++++++++++--- .../tests/test_permanent_delegate.rs | 6 ++---- .../anchor/programs/transfer-fee/Cargo.toml | 15 ++++++++++++--- .../transfer-fee/tests/test_transfer_fee.rs | 6 ++---- .../anchor/programs/transfer-hook/Cargo.toml | 15 ++++++++++++--- .../transfer-hook/tests/test_transfer_hook.rs | 6 ++---- .../anchor/programs/abl-token/Cargo.toml | 15 ++++++++++++--- .../programs/abl-token/tests/test_abl_token.rs | 6 ++---- .../anchor/programs/transfer-hook/Cargo.toml | 15 ++++++++++++--- .../tests/test_transfer_hook_counter.rs | 6 ++---- .../anchor/programs/transfer-hook/Cargo.toml | 15 ++++++++++++--- .../transfer-hook/tests/test_transfer_hook.rs | 6 ++---- .../anchor/programs/transfer-hook/Cargo.toml | 15 ++++++++++++--- .../transfer-hook/tests/test_transfer_hook.rs | 6 ++---- .../anchor/programs/transfer-switch/Cargo.toml | 15 ++++++++++++--- .../transfer-switch/tests/test_transfer_switch.rs | 6 ++---- .../anchor/programs/transfer-hook/Cargo.toml | 15 ++++++++++++--- .../transfer-hook/tests/test_transfer_hook.rs | 6 ++---- .../anchor/programs/token-minter/Cargo.toml | 15 ++++++++++++--- .../token-minter/tests/test_token_minter.rs | 6 ++---- .../anchor/programs/transfer-tokens/Cargo.toml | 15 ++++++++++++--- .../transfer-tokens/tests/test_transfer_tokens.rs | 6 ++---- 117 files changed, 794 insertions(+), 397 deletions(-) diff --git a/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml b/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml index a533e1862..9d86859c0 100644 --- a/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/account-data/anchor/programs/anchor-program-example/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } borsh = "1.6.1" solana-kite = "0.4.0" diff --git a/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs b/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs index 910fb4488..f9cb9f892 100644 --- a/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs +++ b/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; /// Deserialize the AddressInfo account (8-byte discriminator + fields). @@ -22,7 +20,7 @@ struct AddressInfoAccount { #[test] fn test_create_address_info() { let program_id = account_data_anchor_program::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/account_data_anchor_program.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml b/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml index d598743ff..e568c2c34 100644 --- a/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/checking-accounts/anchor/programs/anchor-program-example/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } borsh = "1.6.1" solana-kite = "0.4.0" diff --git a/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs b/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs index 88118fbc0..4cbc9b317 100644 --- a/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs +++ b/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs @@ -1,18 +1,16 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{instruction::Instruction, system_instruction}, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; #[test] fn test_check_accounts() { let program_id = checking_account_program::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/checking_account_program.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/close-account/anchor/programs/close-account/Cargo.toml b/basics/close-account/anchor/programs/close-account/Cargo.toml index f1a78ee1f..8bf9badc7 100644 --- a/basics/close-account/anchor/programs/close-account/Cargo.toml +++ b/basics/close-account/anchor/programs/close-account/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,9 +34,16 @@ wincode = { version = "0.5", features = ["derive"] } solana-address = ">=2.6, <2.7" [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs b/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs index c12b11239..6e620ba28 100644 --- a/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs +++ b/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs @@ -1,17 +1,15 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Keypair) { let program_id = close_account_program::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/close_account_program.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/counter/anchor/programs/counter_anchor/Cargo.toml b/basics/counter/anchor/programs/counter_anchor/Cargo.toml index b6e306811..4200f22fb 100644 --- a/basics/counter/anchor/programs/counter_anchor/Cargo.toml +++ b/basics/counter/anchor/programs/counter_anchor/Cargo.toml @@ -14,6 +14,8 @@ cpi = ["no-entrypoint"] no-entrypoint = [] no-idl = [] no-log-ix-name = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# It is published only from git: crates.io has no `anchor-v2-testing`. Pinned +# to a revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } borsh = "1.6.1" solana-kite = "0.4.0" diff --git a/basics/counter/anchor/programs/counter_anchor/tests/test_counter.rs b/basics/counter/anchor/programs/counter_anchor/tests/test_counter.rs index 755fa0d48..59698f033 100644 --- a/basics/counter/anchor/programs/counter_anchor/tests/test_counter.rs +++ b/basics/counter/anchor/programs/counter_anchor/tests/test_counter.rs @@ -2,11 +2,9 @@ use { anchor_lang::{ solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; /// Minimal deserialization of the Counter account (8-byte discriminator + u64). @@ -18,7 +16,7 @@ struct CounterAccount { fn setup() -> (LiteSVM, anchor_lang::prelude::Address, Keypair) { let program_id = counter_anchor::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/counter_anchor.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/create-account/anchor/programs/create-system-account/Cargo.toml b/basics/create-account/anchor/programs/create-system-account/Cargo.toml index a4b4b1636..f99daf866 100644 --- a/basics/create-account/anchor/programs/create-system-account/Cargo.toml +++ b/basics/create-account/anchor/programs/create-system-account/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs b/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs index 8264d06a6..0872b5396 100644 --- a/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs +++ b/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs @@ -1,18 +1,16 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{instruction::Instruction, rent::Rent}, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; #[test] fn test_create_the_account() { let program_id = create_system_account::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/create_system_account.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml b/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml index 2d7da4375..b9d9525c1 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml +++ b/basics/cross-program-invocation/anchor/programs/hand/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs b/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs index b6c81b4f2..bef325985 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs +++ b/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; /// PowerStatus account layout: 8-byte discriminator + 1-byte bool + 7 bytes padding. @@ -43,7 +41,7 @@ fn test_pull_lever_cpi() { // The lever program ID from declare_program!(lever) inside hand crate let lever_program_id = hand::lever::ID; - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); // Load both programs let hand_bytes = include_bytes!("../../../target/deploy/hand.so"); diff --git a/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml b/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml index 265c9d12f..e126a3d5b 100644 --- a/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml +++ b/basics/cross-program-invocation/anchor/programs/lever/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs b/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs index 87e8c002b..fffeb7535 100644 --- a/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs +++ b/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs @@ -1,11 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; /// PowerStatus account layout: 8-byte discriminator + 1-byte bool + 7 bytes padding. @@ -18,7 +16,7 @@ fn read_power_is_on(svm: &LiteSVM, pubkey: &anchor_lang::prelude::Address) -> bo #[test] fn test_initialize_lever() { let program_id = lever::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/lever.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); @@ -53,7 +51,7 @@ fn test_initialize_lever() { #[test] fn test_switch_power() { let program_id = lever::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/lever.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/favorites/anchor/programs/favorites/Cargo.toml b/basics/favorites/anchor/programs/favorites/Cargo.toml index 0ec0e8e58..631a31209 100644 --- a/basics/favorites/anchor/programs/favorites/Cargo.toml +++ b/basics/favorites/anchor/programs/favorites/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs b/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs index 2f5543adc..dd88f9e7c 100644 --- a/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs +++ b/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs @@ -1,11 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; struct FavoritesData { @@ -53,7 +52,7 @@ fn read_favorites(svm: &LiteSVM, pda: &Address) -> FavoritesData { fn setup() -> (LiteSVM, Address, solana_keypair::Keypair) { let program_id = favorites::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/favorites.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml b/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml index e96bdc106..5efaeb146 100644 --- a/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml +++ b/basics/hello-solana/anchor/programs/hello-solana/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,8 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" solana-transaction = "3.0.1" diff --git a/basics/hello-solana/anchor/programs/hello-solana/tests/test_hello.rs b/basics/hello-solana/anchor/programs/hello-solana/tests/test_hello.rs index 6dd3541db..615095ab1 100644 --- a/basics/hello-solana/anchor/programs/hello-solana/tests/test_hello.rs +++ b/basics/hello-solana/anchor/programs/hello-solana/tests/test_hello.rs @@ -1,15 +1,14 @@ use { anchor_lang::{solana_program::instruction::Instruction, InstructionData, ToAccountMetas}, - litesvm::LiteSVM, + anchor_v2_testing::{LiteSVM, Signer}, solana_kite::create_wallet, - solana_signer::Signer, solana_transaction::Transaction, }; #[test] fn test_say_hello() { let program_id = hello_solana::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/hello_solana.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 1_000_000_000).unwrap(); diff --git a/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml b/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml index 740790332..e39a412ed 100644 --- a/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/pda-rent-payer/anchor/programs/anchor-program-example/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs b/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs index 463207020..c57b44606 100644 --- a/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs +++ b/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs @@ -1,17 +1,15 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Keypair) { let program_id = pda_rent_payer::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/pda_rent_payer.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml b/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml index 4bba91bde..e0fc5fce5 100644 --- a/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml +++ b/basics/processing-instructions/anchor/programs/processing-instructions/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs b/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs index 413688cc4..3b55ca493 100644 --- a/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs +++ b/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs @@ -1,13 +1,12 @@ use { anchor_lang::{solana_program::instruction::Instruction, InstructionData, ToAccountMetas}, - litesvm::LiteSVM, + anchor_v2_testing::{LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; fn setup() -> (LiteSVM, solana_keypair::Keypair) { let program_id = processing_instructions::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/processing_instructions.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml b/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml index 69b670b4c..7a877276e 100644 --- a/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml +++ b/basics/program-derived-addresses/anchor/programs/anchor-program-example/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } borsh = "1.6.1" solana-kite = "0.4.0" diff --git a/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs b/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs index 96d5b028a..8d8a551ee 100644 --- a/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs +++ b/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs @@ -1,17 +1,16 @@ use { anchor_lang::{ + anchor_v2_testing::{LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, - litesvm::LiteSVM, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; fn setup() -> (LiteSVM, solana_keypair::Keypair) { let program_id = program_derived_addresses_program::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/program_derived_addresses_program.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/pyth/anchor/programs/pythexample/Cargo.toml b/basics/pyth/anchor/programs/pythexample/Cargo.toml index 040ca02fe..06974375c 100644 --- a/basics/pyth/anchor/programs/pythexample/Cargo.toml +++ b/basics/pyth/anchor/programs/pythexample/Cargo.toml @@ -19,6 +19,8 @@ anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -31,15 +33,22 @@ wincode = { version = "0.5", features = ["derive"] } solana-address = ">=2.6, <2.7" [dev-dependencies] +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } # Self-dependency with no-entrypoint: host test builds otherwise export a # #[no_mangle] `entrypoint` symbol from this crate AND from spl-token (via # solana-kite), and the linker rejects the duplicate. The SBF build # (cargo build-sbf) ignores dev-dependencies, so the deployed program keeps # its entrypoint. pythexample = { path = ".", features = ["no-entrypoint"] } -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-account = "3.0.0" solana-clock = "3.0.1" borsh = "1.6.1" diff --git a/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs b/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs index 5929d9538..28f5e7c7c 100644 --- a/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs +++ b/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs @@ -1,14 +1,12 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, pythexample::MAXIMUM_PRICE_AGE_SECONDS, // LiteSVM's get_sysvar wants the host-side Clock, not pinocchio's. solana_clock::Clock, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; /// The `publish_time` baked into the mock price update below. @@ -85,7 +83,7 @@ fn setup_with_price_account( owner: anchor_lang::Address, ) -> (LiteSVM, solana_keypair::Keypair, Keypair) { let program_id = pythexample::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/pythexample.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/realloc/anchor/programs/anchor-realloc/Cargo.toml b/basics/realloc/anchor/programs/anchor-realloc/Cargo.toml index 225ed55ca..1ae26a12c 100644 --- a/basics/realloc/anchor/programs/anchor-realloc/Cargo.toml +++ b/basics/realloc/anchor/programs/anchor-realloc/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } borsh = "1.6.1" solana-kite = "0.4.0" diff --git a/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs b/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs index cd6dca049..5d110a779 100644 --- a/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs +++ b/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; #[derive(BorshDeserialize)] @@ -24,7 +22,7 @@ fn fetch_message(svm: &LiteSVM, pubkey: &anchor_lang::prelude::Address) -> Strin #[test] fn test_initialize() { let program_id = anchor_realloc::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/anchor_realloc.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); @@ -64,7 +62,7 @@ fn test_initialize() { #[test] fn test_update_grows() { let program_id = anchor_realloc::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/anchor_realloc.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); @@ -121,7 +119,7 @@ fn test_update_grows() { #[test] fn test_update_shrinks() { let program_id = anchor_realloc::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/anchor_realloc.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/rent/anchor/programs/rent-example/Cargo.toml b/basics/rent/anchor/programs/rent-example/Cargo.toml index f67f2e2c1..29b508d6b 100644 --- a/basics/rent/anchor/programs/rent-example/Cargo.toml +++ b/basics/rent/anchor/programs/rent-example/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/rent/anchor/programs/rent-example/tests/test_rent.rs b/basics/rent/anchor/programs/rent-example/tests/test_rent.rs index 376f1ebc2..1174f937a 100644 --- a/basics/rent/anchor/programs/rent-example/tests/test_rent.rs +++ b/basics/rent/anchor/programs/rent-example/tests/test_rent.rs @@ -1,17 +1,15 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; #[test] fn test_create_system_account() { let program_id = rent_example::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/rent_example.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/repository-layout/anchor/programs/carnival/Cargo.toml b/basics/repository-layout/anchor/programs/carnival/Cargo.toml index 80bc8bd5b..74e066e84 100644 --- a/basics/repository-layout/anchor/programs/carnival/Cargo.toml +++ b/basics/repository-layout/anchor/programs/carnival/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs b/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs index c59114e23..799ce071c 100644 --- a/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs +++ b/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs @@ -1,13 +1,12 @@ use { anchor_lang::{solana_program::instruction::Instruction, InstructionData, ToAccountMetas}, - litesvm::LiteSVM, + anchor_v2_testing::{LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; fn setup() -> (LiteSVM, solana_keypair::Keypair) { let program_id = carnival::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/carnival.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10_000_000_000).unwrap(); diff --git a/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml b/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml index f162a6257..b13aef80d 100644 --- a/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml +++ b/basics/transfer-sol/anchor/programs/transfer-sol/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -26,9 +28,16 @@ anchor-lang = "2.0.0-rc.1" wincode = { version = "0.5", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" [lints.rust] diff --git a/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs b/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs index 7847d442d..35eaf1214 100644 --- a/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs +++ b/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs @@ -1,11 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; const LAMPORTS_PER_SOL: u64 = 1_000_000_000; @@ -13,7 +11,7 @@ const LAMPORTS_PER_SOL: u64 = 1_000_000_000; #[test] fn test_transfer_sol_with_cpi() { let program_id = transfer_sol::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/transfer_sol.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10 * LAMPORTS_PER_SOL).unwrap(); @@ -44,7 +42,7 @@ fn test_transfer_sol_with_cpi() { #[test] fn test_transfer_sol_with_program() { let program_id = transfer_sol::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/transfer_sol.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10 * LAMPORTS_PER_SOL).unwrap(); @@ -93,7 +91,7 @@ fn test_transfer_sol_with_program() { #[test] fn test_transfer_sol_with_program_rejects_insufficient_funds() { let program_id = transfer_sol::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/transfer_sol.so"); svm.add_program(program_id, bytes).unwrap(); let payer = create_wallet(&mut svm, 10 * LAMPORTS_PER_SOL).unwrap(); diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml b/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml index 5744045fd..91376b71e 100644 --- a/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml +++ b/compression/cnft-burn/anchor/programs/cnft-burn/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -37,15 +39,22 @@ solana-address = { version = ">=2.6, <2.7", features = ["borsh"] } borsh = { version = "1", features = ["derive"] } [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" solana-instruction = "3.0.0" -solana-keypair = "3.0.1" solana-pubkey = "3.0.0" solana-transaction = "3.0.0" solana-account = "3.0.0" solana-native-token = "3.0.0" -solana-signer = "3.0.0" solana-message = "3.0.0" solana-keccak-hasher = "3.0.0" diff --git a/compression/cnft-burn/anchor/programs/cnft-burn/tests/test_burn.rs b/compression/cnft-burn/anchor/programs/cnft-burn/tests/test_burn.rs index 819b28fa9..0b5f74386 100644 --- a/compression/cnft-burn/anchor/programs/cnft-burn/tests/test_burn.rs +++ b/compression/cnft-burn/anchor/programs/cnft-burn/tests/test_burn.rs @@ -13,14 +13,12 @@ //! transaction succeeds and a second burn fails (leaf already zeroed). use { + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshSerialize, - litesvm::LiteSVM, solana_instruction::{account_meta::AccountMeta, Instruction}, solana_keccak_hasher::hashv, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, solana_pubkey::{pubkey, Pubkey}, - solana_signer::Signer, }; // ---- Program IDs ---------------------------------------------------------- @@ -240,7 +238,7 @@ fn read_current_root(data: &[u8]) -> [u8; 32] { #[test] fn test_burn_cnft() { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); // Load the cnft-burn program and the three mainnet fixtures. svm.add_program( diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml b/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml index a211e43dc..d3a1a38a8 100644 --- a/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml +++ b/compression/cnft-vault/anchor/programs/cnft-vault/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -40,14 +42,21 @@ borsh = { version = "1", features = ["derive"] } unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("solana"))'] } [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" solana-instruction = "3.0.0" -solana-keypair = "3.0.1" solana-pubkey = "3.0.0" solana-transaction = "3.0.0" solana-account = "3.0.0" solana-native-token = "3.0.0" -solana-signer = "3.0.0" solana-message = "3.0.0" solana-keccak-hasher = "3.0.0" diff --git a/compression/cnft-vault/anchor/programs/cnft-vault/tests/test_vault.rs b/compression/cnft-vault/anchor/programs/cnft-vault/tests/test_vault.rs index ad0ef8801..3fe9a543e 100644 --- a/compression/cnft-vault/anchor/programs/cnft-vault/tests/test_vault.rs +++ b/compression/cnft-vault/anchor/programs/cnft-vault/tests/test_vault.rs @@ -26,15 +26,13 @@ //! of panicking inside `split_at` use { + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshSerialize, cnft_vault::error::VaultError, - litesvm::LiteSVM, solana_instruction::{account_meta::AccountMeta, Instruction}, solana_keccak_hasher::hashv, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions, SolanaKiteError}, solana_pubkey::{pubkey, Pubkey}, - solana_signer::Signer, }; // ---- Program IDs ---------------------------------------------------------- @@ -284,7 +282,7 @@ struct VaultTestContext { } fn setup_vault() -> VaultTestContext { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); // Load the cnft-vault program and the three mainnet fixtures. svm.add_program( diff --git a/compression/cutils/anchor/programs/cutils/Cargo.toml b/compression/cutils/anchor/programs/cutils/Cargo.toml index ca07a7192..3994fc0e9 100644 --- a/compression/cutils/anchor/programs/cutils/Cargo.toml +++ b/compression/cutils/anchor/programs/cutils/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -42,14 +44,21 @@ sha3 = "0.10" unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("solana"))'] } [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" solana-instruction = "3.0.0" -solana-keypair = "3.0.1" solana-pubkey = "3.0.0" solana-transaction = "3.0.0" solana-account = "3.0.0" solana-native-token = "3.0.0" -solana-signer = "3.0.0" solana-message = "3.0.0" solana-keccak-hasher = "3.0.0" diff --git a/compression/cutils/anchor/programs/cutils/tests/test_cutils.rs b/compression/cutils/anchor/programs/cutils/tests/test_cutils.rs index ec00f50d5..84c2e2bcb 100644 --- a/compression/cutils/anchor/programs/cutils/tests/test_cutils.rs +++ b/compression/cutils/anchor/programs/cutils/tests/test_cutils.rs @@ -26,14 +26,12 @@ //! fail. use { + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshSerialize, - litesvm::LiteSVM, solana_instruction::{account_meta::AccountMeta, Instruction}, solana_keccak_hasher::hashv, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, solana_pubkey::{pubkey, Pubkey}, - solana_signer::Signer, }; // ---- Program IDs ---------------------------------------------------------- @@ -464,7 +462,7 @@ fn create_collection_nft( #[test] fn test_cutils_mint_and_verify() { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); // Load the cutils program and the mainnet fixtures. svm.add_program( diff --git a/finance/betting-market/anchor/programs/betting-market/Cargo.toml b/finance/betting-market/anchor/programs/betting-market/Cargo.toml index 9acadab10..2d25aded0 100644 --- a/finance/betting-market/anchor/programs/betting-market/Cargo.toml +++ b/finance/betting-market/anchor/programs/betting-market/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed: place_bet and the lazy User index create accounts only on first use. @@ -33,15 +35,22 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } # no-entrypoint: solana-kite pulls these SPL program crates into the host test # build, and their `entrypoint` symbols collide with this program's own # entrypoint at link time. Feature unification turns their entrypoints off # across the test build; the dependencies exist only for that. spl-token = { version = "9.0.0", features = ["no-entrypoint"] } spl-associated-token-account = { version = "8.0.0", features = ["no-entrypoint"] } -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs b/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs index 16282804f..c881fec90 100644 --- a/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs +++ b/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs @@ -1,17 +1,15 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, betting_market::{User, MAX_BETS_PER_USER}, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; const DECIMALS: u8 = 6; @@ -76,7 +74,7 @@ struct Market { // Spin up the SVM with the program loaded, an admin wallet, the stake-token mint // (admin is the mint authority), and a fee-recipient wallet with an ATA. fn setup() -> Market { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/betting_market.so"); svm.add_program(betting_market::id(), program_bytes) .unwrap(); diff --git a/finance/escrow/anchor/programs/escrow/Cargo.toml b/finance/escrow/anchor/programs/escrow/Cargo.toml index 71fe7fd8a..d8cb08994 100644 --- a/finance/escrow/anchor/programs/escrow/Cargo.toml +++ b/finance/escrow/anchor/programs/escrow/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,9 +34,16 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs index 837a099f8..0a92f87c4 100644 --- a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs +++ b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs @@ -1,16 +1,14 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; fn token_program_id() -> Address { @@ -39,7 +37,7 @@ fn derive_ata(wallet: &Address, mint: &Address) -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = escrow::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/escrow.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/finance/lending/anchor/programs/lending/Cargo.toml b/finance/lending/anchor/programs/lending/Cargo.toml index a0c47fa08..b892555fc 100644 --- a/finance/lending/anchor/programs/lending/Cargo.toml +++ b/finance/lending/anchor/programs/lending/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed: the obligation share vault and the test price feed are created lazily. @@ -36,9 +38,16 @@ pinocchio = "0.11" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" # Test-side only: LiteSVM's get_sysvar/set_sysvar want the host-side sysvar diff --git a/finance/lending/anchor/programs/lending/tests/common/mod.rs b/finance/lending/anchor/programs/lending/tests/common/mod.rs index 2f1803ed4..ce490c299 100644 --- a/finance/lending/anchor/programs/lending/tests/common/mod.rs +++ b/finance/lending/anchor/programs/lending/tests/common/mod.rs @@ -11,13 +11,11 @@ use anchor_lang::{ system_program, AccountDeserialize, InstructionData, ToAccountMetas, }; use anchor_spl::token::ID as TOKEN_PROGRAM_ID; -use litesvm::LiteSVM; -use solana_keypair::Keypair; +use anchor_v2_testing::{Keypair, LiteSVM, Signer}; use solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }; -use solana_signer::Signer; use lending::constants::{ LENDING_MARKET_SEED, LIQUIDITY_VAULT_SEED, OBLIGATION_SEED, OBLIGATION_SHARE_VAULT_SEED, @@ -107,7 +105,7 @@ pub struct Env { impl Env { pub fn new() -> Self { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../../target/deploy/lending.so"); svm.add_program(lending::id(), program_bytes).unwrap(); diff --git a/finance/lending/anchor/programs/lending/tests/test_borrow_repay.rs b/finance/lending/anchor/programs/lending/tests/test_borrow_repay.rs index a31083604..8f173c4f4 100644 --- a/finance/lending/anchor/programs/lending/tests/test_borrow_repay.rs +++ b/finance/lending/anchor/programs/lending/tests/test_borrow_repay.rs @@ -1,10 +1,9 @@ mod common; +use anchor_v2_testing::{Keypair, Signer}; use lending::errors::LendingError; use common::{ata, default_config, dollars, Env, ReserveHandle}; -use solana_keypair::Keypair; -use solana_signer::Signer; /// One market with a collateral reserve and a separately-supplied borrow /// reserve, plus a borrower who has posted 1000 units of collateral (value diff --git a/finance/lending/anchor/programs/lending/tests/test_interest.rs b/finance/lending/anchor/programs/lending/tests/test_interest.rs index e9ac96cf8..61afd65fe 100644 --- a/finance/lending/anchor/programs/lending/tests/test_interest.rs +++ b/finance/lending/anchor/programs/lending/tests/test_interest.rs @@ -1,8 +1,8 @@ mod common; +use anchor_v2_testing::{Signer}; use common::{ata, default_config, dollars, Env, SLOTS_PER_YEAR}; use lending::constants::FIXED_POINT_SCALE; -use solana_signer::Signer; /// Borrowing at non-zero utilization, then letting slots pass, must grow the /// reserve's accumulation factor, the borrower's debt, and the share exchange rate. diff --git a/finance/lending/anchor/programs/lending/tests/test_liquidation.rs b/finance/lending/anchor/programs/lending/tests/test_liquidation.rs index 2fc35216f..39ad5cc3d 100644 --- a/finance/lending/anchor/programs/lending/tests/test_liquidation.rs +++ b/finance/lending/anchor/programs/lending/tests/test_liquidation.rs @@ -1,10 +1,9 @@ mod common; +use anchor_v2_testing::{Keypair, Signer}; use lending::errors::LendingError; use common::{ata, cents, default_config, dollars, Env, ReserveHandle}; -use solana_keypair::Keypair; -use solana_signer::Signer; /// A borrower with $1000 of collateral who has borrowed $700 (healthy at 80% /// liquidation threshold), plus a liquidator funded with the borrow token. diff --git a/finance/lending/anchor/programs/lending/tests/test_rounding.rs b/finance/lending/anchor/programs/lending/tests/test_rounding.rs index 223acae55..1e12b4cb3 100644 --- a/finance/lending/anchor/programs/lending/tests/test_rounding.rs +++ b/finance/lending/anchor/programs/lending/tests/test_rounding.rs @@ -1,9 +1,9 @@ mod common; +use anchor_v2_testing::{Signer}; use lending::errors::LendingError; use common::{ata, default_config, dollars, Env}; -use solana_signer::Signer; /// After interest makes the pool worth more than its share supply, a deposit so /// small it would mint zero shares is rejected rather than silently giving the diff --git a/finance/lending/anchor/programs/lending/tests/test_security.rs b/finance/lending/anchor/programs/lending/tests/test_security.rs index 88be6eaab..9510ab335 100644 --- a/finance/lending/anchor/programs/lending/tests/test_security.rs +++ b/finance/lending/anchor/programs/lending/tests/test_security.rs @@ -1,12 +1,12 @@ mod common; +use anchor_v2_testing::{Signer}; use lending::errors::LendingError; use anchor_lang::{ solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }; use common::{default_config, dollars, Env}; -use solana_signer::Signer; /// A reserve from one lending market cannot be used with an obligation from /// another: lending markets are isolation boundaries. diff --git a/finance/order-book/anchor/programs/order-book/Cargo.toml b/finance/order-book/anchor/programs/order-book/Cargo.toml index 235b4946b..9d4a122b5 100644 --- a/finance/order-book/anchor/programs/order-book/Cargo.toml +++ b/finance/order-book/anchor/programs/order-book/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -38,11 +40,18 @@ bytemuck = { version = "1.18", features = ["derive", "min_const_generics"] } static_assertions = "1.1" [dev-dependencies] +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } # Match the test stack used by finance/escrow and the other LiteSVM-based # Anchor examples so contributors can move between them without version drift. -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" [lints.rust] diff --git a/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs b/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs index e101009c1..5102c7df9 100644 --- a/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs +++ b/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs @@ -11,6 +11,7 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{ instruction::{AccountMeta, Instruction}, system_instruction, @@ -23,14 +24,11 @@ use { InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; // Keep test-side seeds in sync with `programs/order_book/src/state/*`. Duplicated @@ -153,7 +151,7 @@ struct Scenario { fn full_setup() -> Scenario { let program_id = order_book::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/order_book.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml b/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml index 80c7602c8..efc5f1119 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed lets add_liquidity create the provider's liquidity-provider @@ -49,10 +51,17 @@ spl-associated-token-account = { version = "8.0.0", features = ["no-entrypoint"] solana-sysvar = "3" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-clock = "3.0.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" borsh = "1.6.1" # The LiteSVM tests load the compiled mock oracle program; depending on the diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs index 4aeb986f0..89cf0be15 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs @@ -1,17 +1,15 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, perpetual_futures::{instructions::initialize_pool::PoolParameters, state::Pool, state::Side}, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; // Collateral token has 6 decimals (like USDC), so one whole unit is 1_000_000 @@ -82,7 +80,7 @@ impl Market { /// `initialize_pool` rejection instead of panicking, so tests can probe the /// parameter validation. fn try_new(initial_price: i128, parameters: PoolParameters) -> Result { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); svm.add_program( perpetual_futures::id(), include_bytes!("../../../target/deploy/perpetual_futures.so"), diff --git a/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml b/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml index fe4d36b22..a0b46c8b7 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml +++ b/finance/prop-amm/anchor/programs/prop-amm/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] # init-if-needed: swap creates the trader's destination token account when it @@ -46,10 +48,17 @@ spl-token = { version = "9.0.0", features = ["no-entrypoint"] } spl-associated-token-account = { version = "8.0.0", features = ["no-entrypoint"] } [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-clock = "3.0.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" borsh = "1.6.1" # The LiteSVM tests load the compiled mock oracle program; depending on the diff --git a/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs b/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs index 8ec07e9e4..b5c17cad1 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, prop_amm::{ instructions::initialize_market::MarketParameters, state::{Direction, Market as MarketState}, }, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; // Both tokens have 6 decimals: the base is NVDAx (tokenized NVIDIA stock) and @@ -86,7 +84,7 @@ impl Market { /// `initialize_market` rejection instead of panicking, so tests can probe /// the parameter validation. fn try_new(initial_price: i128, parameters: MarketParameters) -> Result { - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); svm.add_program( prop_amm::id(), include_bytes!("../../../target/deploy/prop_amm.so"), diff --git a/finance/token-fundraiser/anchor/programs/fundraiser/Cargo.toml b/finance/token-fundraiser/anchor/programs/fundraiser/Cargo.toml index 1294231ad..e33335bca 100644 --- a/finance/token-fundraiser/anchor/programs/fundraiser/Cargo.toml +++ b/finance/token-fundraiser/anchor/programs/fundraiser/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -32,10 +34,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-clock = "3.0.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" borsh = "1.6.1" # solana-kite depends on these SPL program crates without "no-entrypoint", diff --git a/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs b/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs index fb386016c..64e403f46 100644 --- a/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs +++ b/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, fundraiser::SECONDS_TO_DAYS, - litesvm::LiteSVM, // LiteSVM's get_sysvar wants the host-side Clock, not pinocchio's. solana_clock::Clock, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; const MINT_DECIMALS: u8 = 6; @@ -98,7 +96,7 @@ struct FundraiserSetup { fn full_setup() -> FundraiserSetup { let program_id = fundraiser::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/fundraiser.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/finance/token-swap/anchor/programs/token-swap/Cargo.toml b/finance/token-swap/anchor/programs/token-swap/Cargo.toml index e51ba2448..0e37aafd3 100644 --- a/finance/token-swap/anchor/programs/token-swap/Cargo.toml +++ b/finance/token-swap/anchor/programs/token-swap/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -35,9 +37,16 @@ anchor-spl = "2.0.0-rc.1" # fixed-point types are not used for money in this program. [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs b/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs index b7d5348b4..910546cad 100644 --- a/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs +++ b/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs @@ -2,17 +2,15 @@ use swap_example::errors::AmmError; use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; fn token_program_id() -> Address { @@ -37,7 +35,7 @@ fn derive_ata(wallet: &Address, mint: &Address) -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = swap_example::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/swap_example.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/finance/vault-strategy/anchor/programs/vault-strategy/Cargo.toml b/finance/vault-strategy/anchor/programs/vault-strategy/Cargo.toml index d978a46cc..be4eb5658 100644 --- a/finance/vault-strategy/anchor/programs/vault-strategy/Cargo.toml +++ b/finance/vault-strategy/anchor/programs/vault-strategy/Cargo.toml @@ -23,6 +23,8 @@ idl-build = ["anchor-lang/idl-build", "mock-swap-router/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -38,11 +40,18 @@ anchor-spl = "2.0.0-rc.1" mock-swap-router = { path = "../mock-swap-router", features = ["cpi"] } [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-clock = "3.0.1" solana-account = "3.0.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs b/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs index 392883277..39be2760d 100644 --- a/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs +++ b/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{instruction::AccountMeta, instruction::Instruction}, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, anchor_spl::token::spl_token, - litesvm::LiteSVM, solana_account::Account as SolanaAccount, // LiteSVM's get_sysvar / set_sysvar want the host-side Clock, not pinocchio's. solana_clock::Clock, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; fn token_program_id() -> Address { @@ -134,7 +132,7 @@ fn setup_full() -> TestContext { let vault_program_id = vault_strategy::id(); let router_program_id = mock_swap_router::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); svm.add_program( vault_program_id, include_bytes!("../../../target/deploy/vault_strategy.so"), diff --git a/tokens/create-token/anchor/programs/create-token/Cargo.toml b/tokens/create-token/anchor/programs/create-token/Cargo.toml index 6ccd329cd..69febf952 100644 --- a/tokens/create-token/anchor/programs/create-token/Cargo.toml +++ b/tokens/create-token/anchor/programs/create-token/Cargo.toml @@ -19,6 +19,8 @@ anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -33,9 +35,16 @@ solana-address = ">=2.6, <2.7" anchor-spl = { version = "2.0.0-rc.1", features = ["metadata"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs b/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs index 8c4658322..b5c56e4a4 100644 --- a/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs +++ b/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; fn metadata_program_id() -> Address { @@ -29,7 +27,7 @@ fn rent_sysvar_id() -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = create_token::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/create_token.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml index 321fc7029..69ea3efa9 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -34,12 +36,19 @@ sha3 = "0.10.8" solana-secp256k1-recover = "2.0.0" [dev-dependencies] +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } # Signs test transfer authorizations with a fixed secp256k1 key so tests can # exercise the Ethereum-signature path end to end. libsecp256k1 = "0.7.2" -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs index 840fc67e5..f3731662e 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs @@ -1,18 +1,16 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, - litesvm::LiteSVM, sha3::{Digest, Keccak256}, - solana_keypair::Keypair, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, send_transaction_from_instructions, }, - solana_signer::Signer, }; const WALLET_LAMPORTS: u64 = 10_000_000_000; @@ -93,7 +91,7 @@ fn sign_transfer_authorization( fn setup() -> (LiteSVM, Address, Keypair) { let program_id = external_delegate_token_master::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/external_delegate_token_master.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/nft-minter/anchor/programs/nft-minter/Cargo.toml b/tokens/nft-minter/anchor/programs/nft-minter/Cargo.toml index c528c3b77..fa8570dd7 100644 --- a/tokens/nft-minter/anchor/programs/nft-minter/Cargo.toml +++ b/tokens/nft-minter/anchor/programs/nft-minter/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,9 +34,16 @@ solana-address = ">=2.6, <2.7" anchor-spl = { version = "2.0.0-rc.1", features = ["metadata"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs b/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs index f850acc46..718d673cf 100644 --- a/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs +++ b/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, - solana_signer::Signer, }; fn token_program_id() -> Address { @@ -66,7 +64,7 @@ fn derive_edition_pda(mint: &Address) -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = nft_minter::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/nft_minter.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/nft-operations/anchor/programs/mint-nft/Cargo.toml b/tokens/nft-operations/anchor/programs/mint-nft/Cargo.toml index ed8eb4d18..21d067dc9 100644 --- a/tokens/nft-operations/anchor/programs/mint-nft/Cargo.toml +++ b/tokens/nft-operations/anchor/programs/mint-nft/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -32,9 +34,16 @@ solana-address = ">=2.6, <2.7" anchor-spl = { version = "2.0.0-rc.1", features = ["metadata"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs b/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs index 739719c4c..2ad3145d8 100644 --- a/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs +++ b/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, - solana_signer::Signer, }; fn token_program_id() -> Address { @@ -75,7 +73,7 @@ fn contains_bytes(haystack: &[u8], needle: &[u8]) -> bool { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = mint_nft::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/mint_nft.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml b/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml index 89d54c306..0a7a1facb 100644 --- a/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml +++ b/tokens/pda-mint-authority/anchor/programs/token-minter/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -35,9 +37,16 @@ anchor-spl = { version = "2.0.0-rc.1", features = ["metadata"] } solana-program-pack = "3" [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs b/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs index 1c5f80a28..3de594b71 100644 --- a/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs +++ b/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, - solana_signer::Signer, }; /// Decimals configured by the program's `mint::decimals` constraint in @@ -62,7 +60,7 @@ fn derive_ata(wallet: &Address, mint: &Address) -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = token_minter::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/token_minter.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml b/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml index 595ef823e..4f2ae8e69 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml +++ b/tokens/token-extensions/basics/anchor/programs/basics/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-spl = "2.0.0-rc.1" @@ -32,10 +34,17 @@ wincode = { version = "0.5", features = ["derive"] } solana-address = ">=2.6, <2.7" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs b/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs index 589ed2506..31862f680 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs @@ -1,15 +1,13 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{get_token_extensions_account_address, TOKEN_EXTENSIONS_PROGRAM_ID}, }, - solana_signer::Signer, }; fn associated_token_program_id() -> Address { @@ -20,7 +18,7 @@ fn associated_token_program_id() -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = anchor::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/anchor.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml index b684815f9..fe41e79fa 100644 --- a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml +++ b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,10 +34,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs index 7bb8c0c29..e6ccb438f 100644 --- a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs +++ b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -12,12 +11,11 @@ use { TOKEN_EXTENSIONS_PROGRAM_ID, }, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = cpi_guard::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/cpi_guard.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml index 23e284f69..850571a7f 100644 --- a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml +++ b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,10 +34,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs index a14e03727..72b000241 100644 --- a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs +++ b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs @@ -1,15 +1,13 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{mint_tokens_to_token_extensions_account, TOKEN_EXTENSIONS_PROGRAM_ID}, }, - solana_signer::Signer, }; /// Create a Token Extensions token account (165 bytes, no extra extensions). @@ -45,7 +43,7 @@ fn create_token_account_instruction( fn setup() -> (LiteSVM, Address, Keypair) { let program_id = default_account_state::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/default_account_state.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/group/anchor/programs/group/Cargo.toml b/tokens/token-extensions/group/anchor/programs/group/Cargo.toml index d6c91ba9b..f86e8b394 100644 --- a/tokens/token-extensions/group/anchor/programs/group/Cargo.toml +++ b/tokens/token-extensions/group/anchor/programs/group/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,10 +34,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs b/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs index 786d957f3..242d98446 100644 --- a/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs +++ b/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs @@ -1,20 +1,19 @@ use { anchor_lang::{ + anchor_v2_testing::{LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, }, - solana_signer::Signer, }; #[test] fn test_initialize_group() { let program_id = group::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/group.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml index a7531d126..a28f34a0a 100644 --- a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml +++ b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,10 +34,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs index 1c4fb438c..80dfe4725 100644 --- a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs +++ b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs @@ -1,15 +1,13 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{create_token_extensions_mint, TOKEN_EXTENSIONS_PROGRAM_ID}, }, - solana_signer::Signer, }; /// SetAuthority instruction for Token Extensions (instruction 6). @@ -42,7 +40,7 @@ fn set_authority_instruction( fn setup() -> (LiteSVM, Address, Keypair) { let program_id = immutable_owner::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/immutable_owner.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml index 64866ee57..728421698 100644 --- a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml +++ b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/Cargo.toml @@ -19,6 +19,8 @@ anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -33,10 +35,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs index e62e0418c..2b2b052a5 100644 --- a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs +++ b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = interest_bearing::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/interest_bearing.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml index 86f284f02..9dca5b656 100644 --- a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml +++ b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,10 +34,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs index 666925b60..be82cbcac 100644 --- a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs +++ b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -12,7 +11,6 @@ use { TOKEN_EXTENSIONS_PROGRAM_ID, }, }, - solana_signer::Signer, }; fn memo_program_id() -> Address { @@ -88,7 +86,7 @@ fn memo_instruction(memo_text: &str, signers: &[&Address]) -> Instruction { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = memo_transfer::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/memo_transfer.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml b/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml index 424caed88..3f573a334 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -34,10 +36,17 @@ spl-token-metadata-interface = "0.8.0" spl-type-length-value = "0.9.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs b/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs index b545fc66d..97d46cc61 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = metadata::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/metadata.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml index 6270fb556..a28a10b83 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml +++ b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/Cargo.toml @@ -15,6 +15,8 @@ no-entrypoint = [] no-idl = [] no-log-ix-name = [] idl-build = ["anchor-lang/idl-build"] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -29,10 +31,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs index f6ba86211..73c1843ed 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs +++ b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = mint_close_authority::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/mint_close_authority.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/Cargo.toml b/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/Cargo.toml index b7d115789..1e882f915 100644 --- a/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/Cargo.toml +++ b/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/Cargo.toml @@ -19,6 +19,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -47,11 +49,18 @@ anchor-spl = { version = "2.0.0-rc.1" } # re-exports keeps a single, consistent type universe. [dev-dependencies] +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } # Test-side decode of the player account's borsh payload. borsh = "1.6.1" -litesvm = "0.13.1" -solana-keypair = "3.0.1" -solana-signer = "3.0.0" solana-instruction = "3.0.0" solana-pubkey = "3.0.0" solana-kite = "0.4.0" diff --git a/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/tests/test_extension_nft.rs b/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/tests/test_extension_nft.rs index 18c656b02..083d07108 100644 --- a/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/tests/test_extension_nft.rs +++ b/tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/tests/test_extension_nft.rs @@ -23,11 +23,9 @@ use { // `system_program` moved to the crate root in v2, and `Pubkey` is // compat-only: `Address` is the same 32-byte type. anchor_lang::{system_program, Address as Pubkey, InstructionData, ToAccountMetas}, - litesvm::LiteSVM, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_instruction::Instruction, - solana_keypair::Keypair, solana_kite::{create_wallet, get_pda_and_bump, send_transaction_from_instructions, Seed}, - solana_signer::Signer, }; // Token Extensions and Associated-Token-Account program ids (the modern, fixed @@ -42,7 +40,7 @@ const LEVEL_SEED: &str = "level1"; fn setup() -> (LiteSVM, Pubkey) { let program_id = extension_nft::ID; - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/extension_nft.so"); svm.add_program(program_id, bytes).unwrap(); (svm, program_id) diff --git a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml index 51bba60b9..3d512b354 100644 --- a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml +++ b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/Cargo.toml @@ -15,6 +15,8 @@ no-entrypoint = [] no-idl = [] no-log-ix-name = [] idl-build = ["anchor-lang/idl-build"] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -29,10 +31,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs index 7727dfc11..39cafc111 100644 --- a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs +++ b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -13,12 +12,11 @@ use { TOKEN_EXTENSIONS_PROGRAM_ID, }, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = non_transferable::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/non_transferable.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml index 2b6fb0b21..a1107c826 100644 --- a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml +++ b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/Cargo.toml @@ -19,6 +19,8 @@ anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -33,10 +35,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs index 372a0b5d0..113d285b4 100644 --- a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs +++ b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{mint_tokens_to_token_extensions_account, TOKEN_EXTENSIONS_PROGRAM_ID}, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = permanent_delegate::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/permanent_delegate.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml index 5746212d6..784466b35 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/Cargo.toml @@ -15,6 +15,8 @@ no-entrypoint = [] no-idl = [] no-log-ix-name = [] idl-build = ["anchor-lang/idl-build"] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -29,10 +31,17 @@ solana-address = ">=2.6, <2.7" anchor-spl = "2.0.0-rc.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs index bb9a2b8ae..04a9bbb8d 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -12,7 +11,6 @@ use { mint_tokens_to_token_extensions_account, TOKEN_EXTENSIONS_PROGRAM_ID, }, }, - solana_signer::Signer, }; fn associated_token_program_id() -> Address { @@ -23,7 +21,7 @@ fn associated_token_program_id() -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_fee::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_fee.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml index 20625e132..cd66ccf2e 100644 --- a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/Cargo.toml @@ -26,6 +26,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -43,10 +45,17 @@ spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index e5b7f4f2b..9a024cd25 100644 --- a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,11 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -15,7 +14,6 @@ use { }, transfer_hook::{build_hook_accounts, get_hook_accounts_address, HookAccount}, }, - solana_signer::Signer, }; /// Deserialize the CounterAccount (8-byte discriminator + fields). @@ -41,7 +39,7 @@ fn associated_token_program_id() -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_hook::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_hook.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml index 352ae672e..cce40b87b 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/Cargo.toml @@ -23,6 +23,8 @@ anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] # interface-instructions feature was removed in Anchor 1.0 and does not exist in v2 @@ -44,10 +46,17 @@ spl-transfer-hook-interface = { version = "2.1.0" } spl-discriminator = "0.5.1" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs index bc3b7e4e2..634b55360 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs @@ -1,20 +1,18 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = abl_token::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/abl_token.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml index 86a4500f7..3cb5ea97f 100644 --- a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/Cargo.toml @@ -26,6 +26,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -43,10 +45,17 @@ spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs index 5fc389b08..8241a7020 100644 --- a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs +++ b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs @@ -1,11 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, borsh::BorshDeserialize, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -15,7 +14,6 @@ use { }, transfer_hook::{build_hook_accounts, get_hook_accounts_address, HookAccount}, }, - solana_signer::Signer, }; /// Deserialize the CounterAccount (8-byte discriminator + fields). @@ -41,7 +39,7 @@ fn associated_token_program_id() -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_hook::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_hook.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml index be1df3a20..5487b84b8 100644 --- a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/Cargo.toml @@ -26,6 +26,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -43,10 +45,17 @@ spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index f839dcea8..eeb17236d 100644 --- a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -14,7 +13,6 @@ use { }, transfer_hook::{build_hook_accounts, get_hook_accounts_address}, }, - solana_signer::Signer, }; fn associated_token_program_id() -> Address { @@ -25,7 +23,7 @@ fn associated_token_program_id() -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_hook::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_hook.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml index 66ba897cc..887a37580 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/Cargo.toml @@ -26,6 +26,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -44,10 +46,17 @@ spl-tlv-account-resolution = "0.11.1" spl-transfer-hook-interface = "2.1.0" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index f67139775..644d457b5 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -12,12 +11,11 @@ use { }, transfer_hook::get_hook_accounts_address, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_hook::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_hook.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml index 363c1f6d8..673486409 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/Cargo.toml @@ -22,6 +22,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -39,10 +41,17 @@ spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs index f81d50ba1..3ffd6c390 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -14,12 +13,11 @@ use { }, transfer_hook::{build_hook_accounts, get_hook_accounts_address, HookAccount}, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_switch::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_switch.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/Cargo.toml b/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/Cargo.toml index 424479303..4532dc1ec 100644 --- a/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/Cargo.toml +++ b/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/Cargo.toml @@ -26,6 +26,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = { version = "2.0.0-rc.1", features = ["compat"] } @@ -43,10 +45,17 @@ spl-tlv-account-resolution = "0.9.0" spl-transfer-hook-interface = "0.9.0" [dev-dependencies] -litesvm = "0.13.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" borsh = "1.6.1" [lints.rust] diff --git a/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index ece754b6d..f4021e5e8 100644 --- a/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,10 +1,9 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ @@ -14,12 +13,11 @@ use { }, transfer_hook::{build_hook_accounts, get_hook_accounts_address, HookAccount}, }, - solana_signer::Signer, }; fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_hook::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_hook.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/token-minter/anchor/programs/token-minter/Cargo.toml b/tokens/token-minter/anchor/programs/token-minter/Cargo.toml index b35258de5..3e7afb6d4 100644 --- a/tokens/token-minter/anchor/programs/token-minter/Cargo.toml +++ b/tokens/token-minter/anchor/programs/token-minter/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,9 +34,16 @@ solana-address = ">=2.6, <2.7" anchor-spl = { version = "2.0.0-rc.1", features = ["metadata"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs b/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs index 389cff2b0..bb8b02b9e 100644 --- a/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs +++ b/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, - solana_signer::Signer, }; /// Decimals configured by the program's `mint::decimals` constraint in @@ -62,7 +60,7 @@ fn derive_ata(wallet: &Address, mint: &Address) -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = token_minter::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/token_minter.so"); svm.add_program(program_id, program_bytes).unwrap(); diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml b/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml index 52dbac2a8..d83d53fcf 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/Cargo.toml @@ -18,6 +18,8 @@ idl-build = ["anchor-lang/idl-build"] anchor-debug = [] custom-heap = [] custom-panic = [] +# Forwards to the harness so `anchor test --profile` can turn tracing on. +profile = ["anchor-v2-testing/profile"] [dependencies] anchor-lang = "2.0.0-rc.1" @@ -32,9 +34,16 @@ solana-address = ">=2.6, <2.7" anchor-spl = { version = "2.0.0-rc.1", features = ["metadata"] } [dev-dependencies] -litesvm = "0.13.1" -solana-signer = "3.0.0" -solana-keypair = "3.0.1" +# Anchor v2's own LiteSVM harness. `svm()` is `LiteSVM::new()` until the +# `profile` feature is on, when it also records the SBF register traces that +# `anchor test --profile`, `anchor debugger` and `anchor coverage` read. Tests +# that call `LiteSVM::new()` directly still pass but produce no traces, so +# those three tools see nothing. +# +# Published only from git: crates.io has no `anchor-v2-testing`. Pinned to a +# revision rather than tracking `anchor-next`, so a CI run cannot change +# behaviour because upstream moved between builds. +anchor-v2-testing = { git = "https://github.com/otter-sec/anchor.git", rev = "3e38a121b969d1a77230baeb0056baf5cc9b3c1a" } solana-kite = "0.4.0" borsh = "1.6.1" diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs index 55a1c6e35..5c73422e4 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs @@ -1,12 +1,10 @@ use { anchor_lang::{ + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, - solana_signer::Signer, }; /// Decimals configured by the program's `mint::decimals` constraint in @@ -62,7 +60,7 @@ fn derive_ata(wallet: &Address, mint: &Address) -> Address { fn setup() -> (LiteSVM, Address, Keypair) { let program_id = transfer_tokens::id(); - let mut svm = LiteSVM::new(); + let mut svm = anchor_v2_testing::svm(); let program_bytes = include_bytes!("../../../target/deploy/transfer_tokens.so"); svm.add_program(program_id, program_bytes).unwrap(); From c90a360a32d22bded517eab662ae284dd0853ddf Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 18:15:23 +0000 Subject: [PATCH 2/4] test: put the harness import at the top level, not inside anchor_lang The first pass inserted `anchor_v2_testing::{...}` wherever the first alphabetically-later entry appeared, without checking how deep in the `use` tree that entry was. In a block like use { anchor_lang::{ solana_program::instruction::Instruction, system_program, ... }, ... }; the first later entry is `solana_program`, nested one level inside `anchor_lang`, so the import landed there and every affected crate failed to compile with `unresolved import anchor_lang::anchor_v2_testing`. The insertion point is now pinned to depth exactly 1, the top level of the outer block. Five test files also named the replaced crates by full path rather than importing them, mostly in helper signatures like `fn setup() -> (LiteSVM, solana_keypair::Keypair)`. Dropping the dev-dependencies left those paths dangling, so they now resolve through the harness too. A local build-and-test sweep caught both: 44 of the 51 projects it reached failed on the first, two on the second. The three shapes are re-verified: account-data (nested block import), processing-instructions and repository-layout (full-path references) all build and pass. --- .../anchor-program-example/tests/test_account_data.rs | 2 +- .../tests/test_checking_accounts.rs | 2 +- .../programs/close-account/tests/test_close_account.rs | 2 +- .../create-system-account/tests/test_create_account.rs | 2 +- .../anchor/programs/hand/tests/test_hand.rs | 2 +- .../anchor/programs/lever/tests/test_lever.rs | 2 +- .../anchor/programs/favorites/tests/test_favorites.rs | 4 ++-- .../anchor-program-example/tests/test_pda_rent_payer.rs | 2 +- .../tests/test_processing_instructions.rs | 2 +- .../tests/test_program_derived_addresses.rs | 4 ++-- .../pyth/anchor/programs/pythexample/tests/test_pyth.rs | 4 ++-- .../anchor/programs/anchor-realloc/tests/test_realloc.rs | 2 +- .../rent/anchor/programs/rent-example/tests/test_rent.rs | 2 +- .../anchor/programs/carnival/tests/test_carnival.rs | 8 ++++---- .../programs/transfer-sol/tests/test_transfer_sol.rs | 2 +- .../programs/betting-market/tests/test_betting_market.rs | 2 +- .../escrow/anchor/programs/escrow/tests/test_escrow.rs | 2 +- .../anchor/programs/order-book/tests/test_order_book.rs | 2 +- .../perpetual-futures/tests/test_perpetual_futures.rs | 2 +- .../anchor/programs/prop-amm/tests/test_prop_amm.rs | 2 +- .../anchor/programs/fundraiser/tests/test_fundraiser.rs | 2 +- .../anchor/programs/token-swap/tests/test_swap.rs | 2 +- .../programs/vault-strategy/tests/vault_strategy.rs | 2 +- .../programs/create-token/tests/test_create_token.rs | 2 +- .../tests/test_external_delegate.rs | 2 +- .../anchor/programs/nft-minter/tests/test_nft_minter.rs | 2 +- .../anchor/programs/mint-nft/tests/test_nft_operations.rs | 2 +- .../anchor/programs/token-minter/tests/test_pda_mint.rs | 2 +- .../basics/anchor/programs/basics/tests/test_basics.rs | 2 +- .../anchor/programs/cpi-guard/tests/test_cpi_guard.rs | 2 +- .../tests/test_default_account_state.rs | 2 +- .../group/anchor/programs/group/tests/test_group.rs | 2 +- .../immutable-owner/tests/test_immutable_owner.rs | 2 +- .../interest-bearing/tests/test_interest_bearing.rs | 2 +- .../programs/memo-transfer/tests/test_memo_transfer.rs | 2 +- .../anchor/programs/metadata/tests/test_metadata.rs | 2 +- .../tests/test_mint_close_authority.rs | 2 +- .../non-transferable/tests/test_non_transferable.rs | 2 +- .../permanent-delegate/tests/test_permanent_delegate.rs | 2 +- .../programs/transfer-fee/tests/test_transfer_fee.rs | 2 +- .../programs/transfer-hook/tests/test_transfer_hook.rs | 2 +- .../anchor/programs/abl-token/tests/test_abl_token.rs | 2 +- .../transfer-hook/tests/test_transfer_hook_counter.rs | 2 +- .../programs/transfer-hook/tests/test_transfer_hook.rs | 2 +- .../programs/transfer-hook/tests/test_transfer_hook.rs | 2 +- .../transfer-switch/tests/test_transfer_switch.rs | 2 +- .../programs/transfer-hook/tests/test_transfer_hook.rs | 2 +- .../programs/token-minter/tests/test_token_minter.rs | 2 +- .../transfer-tokens/tests/test_transfer_tokens.rs | 2 +- 49 files changed, 55 insertions(+), 55 deletions(-) diff --git a/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs b/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs index f9cb9f892..2a41ec80d 100644 --- a/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs +++ b/basics/account-data/anchor/programs/anchor-program-example/tests/test_account_data.rs @@ -1,8 +1,8 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs b/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs index 4cbc9b317..dc1226e52 100644 --- a/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs +++ b/basics/checking-accounts/anchor/programs/anchor-program-example/tests/test_checking_accounts.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{instruction::Instruction, system_instruction}, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs b/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs index 6e620ba28..844e06a95 100644 --- a/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs +++ b/basics/close-account/anchor/programs/close-account/tests/test_close_account.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs b/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs index 0872b5396..8717a3e62 100644 --- a/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs +++ b/basics/create-account/anchor/programs/create-system-account/tests/test_create_account.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{instruction::Instruction, rent::Rent}, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs b/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs index bef325985..a5e333b24 100644 --- a/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs +++ b/basics/cross-program-invocation/anchor/programs/hand/tests/test_hand.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs b/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs index fffeb7535..38ca75616 100644 --- a/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs +++ b/basics/cross-program-invocation/anchor/programs/lever/tests/test_lever.rs @@ -1,8 +1,8 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs b/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs index dd88f9e7c..48b64f75a 100644 --- a/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs +++ b/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; @@ -50,7 +50,7 @@ fn read_favorites(svm: &LiteSVM, pda: &Address) -> FavoritesData { } } -fn setup() -> (LiteSVM, Address, solana_keypair::Keypair) { +fn setup() -> (LiteSVM, Address, anchor_v2_testing::Keypair) { let program_id = favorites::id(); let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/favorites.so"); diff --git a/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs b/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs index c57b44606..357672709 100644 --- a/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs +++ b/basics/pda-rent-payer/anchor/programs/anchor-program-example/tests/test_pda_rent_payer.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs b/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs index 3b55ca493..541771b1b 100644 --- a/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs +++ b/basics/processing-instructions/anchor/programs/processing-instructions/tests/test_processing_instructions.rs @@ -4,7 +4,7 @@ use { solana_kite::{create_wallet, send_transaction_from_instructions}, }; -fn setup() -> (LiteSVM, solana_keypair::Keypair) { +fn setup() -> (LiteSVM, anchor_v2_testing::Keypair) { let program_id = processing_instructions::id(); let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/processing_instructions.so"); diff --git a/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs b/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs index 8d8a551ee..67637369f 100644 --- a/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs +++ b/basics/program-derived-addresses/anchor/programs/anchor-program-example/tests/test_program_derived_addresses.rs @@ -1,14 +1,14 @@ use { anchor_lang::{ - anchor_v2_testing::{LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{LiteSVM, Signer}, borsh::BorshDeserialize, solana_kite::{create_wallet, send_transaction_from_instructions}, }; -fn setup() -> (LiteSVM, solana_keypair::Keypair) { +fn setup() -> (LiteSVM, anchor_v2_testing::Keypair) { let program_id = program_derived_addresses_program::id(); let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/program_derived_addresses_program.so"); diff --git a/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs b/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs index 28f5e7c7c..acd4fb66a 100644 --- a/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs +++ b/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs @@ -1,8 +1,8 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, pythexample::MAXIMUM_PRICE_AGE_SECONDS, // LiteSVM's get_sysvar wants the host-side Clock, not pinocchio's. solana_clock::Clock, @@ -81,7 +81,7 @@ fn set_clock_to_price_age(svm: &mut LiteSVM, age_seconds: i64) { fn setup_with_price_account( owner: anchor_lang::Address, -) -> (LiteSVM, solana_keypair::Keypair, Keypair) { +) -> (LiteSVM, anchor_v2_testing::Keypair, Keypair) { let program_id = pythexample::id(); let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/pythexample.so"); diff --git a/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs b/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs index 5d110a779..2ad901bf5 100644 --- a/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs +++ b/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs @@ -1,8 +1,8 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/rent/anchor/programs/rent-example/tests/test_rent.rs b/basics/rent/anchor/programs/rent-example/tests/test_rent.rs index 1174f937a..deb13f057 100644 --- a/basics/rent/anchor/programs/rent-example/tests/test_rent.rs +++ b/basics/rent/anchor/programs/rent-example/tests/test_rent.rs @@ -1,8 +1,8 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs b/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs index 799ce071c..f62972024 100644 --- a/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs +++ b/basics/repository-layout/anchor/programs/carnival/tests/test_carnival.rs @@ -4,7 +4,7 @@ use { solana_kite::{create_wallet, send_transaction_from_instructions}, }; -fn setup() -> (LiteSVM, solana_keypair::Keypair) { +fn setup() -> (LiteSVM, anchor_v2_testing::Keypair) { let program_id = carnival::id(); let mut svm = anchor_v2_testing::svm(); let bytes = include_bytes!("../../../target/deploy/carnival.so"); @@ -14,7 +14,7 @@ fn setup() -> (LiteSVM, solana_keypair::Keypair) { } fn go_on_ride_ix( - payer: &solana_keypair::Keypair, + payer: &anchor_v2_testing::Keypair, name: &str, height: u32, ticket_count: u32, @@ -38,7 +38,7 @@ fn go_on_ride_ix( } fn play_game_ix( - payer: &solana_keypair::Keypair, + payer: &anchor_v2_testing::Keypair, name: &str, ticket_count: u32, game_name: &str, @@ -60,7 +60,7 @@ fn play_game_ix( } fn eat_food_ix( - payer: &solana_keypair::Keypair, + payer: &anchor_v2_testing::Keypair, name: &str, ticket_count: u32, food_stand_name: &str, diff --git a/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs b/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs index 35eaf1214..b3c405988 100644 --- a/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs +++ b/basics/transfer-sol/anchor/programs/transfer-sol/tests/test_transfer_sol.rs @@ -1,8 +1,8 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs b/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs index c881fec90..ce27640dc 100644 --- a/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs +++ b/finance/betting-market/anchor/programs/betting-market/tests/test_betting_market.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, betting_market::{User, MAX_BETS_PER_USER}, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, diff --git a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs index 0a92f87c4..6f02572da 100644 --- a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs +++ b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, diff --git a/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs b/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs index 5102c7df9..8ae090130 100644 --- a/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs +++ b/finance/order-book/anchor/programs/order-book/tests/test_order_book.rs @@ -11,7 +11,6 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{ instruction::{AccountMeta, Instruction}, system_instruction, @@ -24,6 +23,7 @@ use { InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, diff --git a/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs b/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs index 89cf0be15..ce691059f 100644 --- a/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs +++ b/finance/perpetual-futures/anchor/programs/perpetual-futures/tests/test_perpetual_futures.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, perpetual_futures::{instructions::initialize_pool::PoolParameters, state::Pool, state::Side}, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, diff --git a/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs b/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs index b5c17cad1..0ff238a0f 100644 --- a/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs +++ b/finance/prop-amm/anchor/programs/prop-amm/tests/test_prop_amm.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, prop_amm::{ instructions::initialize_market::MarketParameters, state::{Direction, Market as MarketState}, diff --git a/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs b/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs index 64e403f46..0bfa52d28 100644 --- a/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs +++ b/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, fundraiser::SECONDS_TO_DAYS, // LiteSVM's get_sysvar wants the host-side Clock, not pinocchio's. diff --git a/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs b/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs index 910546cad..8a68bbb5f 100644 --- a/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs +++ b/finance/token-swap/anchor/programs/token-swap/tests/test_swap.rs @@ -2,10 +2,10 @@ use swap_example::errors::AmmError; use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_associated_token_account, create_token_mint, create_wallet, get_token_account_balance, mint_tokens_to_token_account, diff --git a/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs b/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs index 39be2760d..0dea9d092 100644 --- a/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs +++ b/finance/vault-strategy/anchor/programs/vault-strategy/tests/vault_strategy.rs @@ -1,10 +1,10 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::{instruction::AccountMeta, instruction::Instruction}, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, anchor_spl::token::spl_token, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_account::Account as SolanaAccount, // LiteSVM's get_sysvar / set_sysvar want the host-side Clock, not pinocchio's. solana_clock::Clock, diff --git a/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs b/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs index b5c56e4a4..dbd90cc05 100644 --- a/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs +++ b/tokens/create-token/anchor/programs/create-token/tests/test_create_token.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, }; diff --git a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs index f3731662e..fa045bc37 100644 --- a/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs +++ b/tokens/external-delegate-token-master/anchor/programs/external-delegate-token-master/tests/test_external_delegate.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, sha3::{Digest, Keccak256}, solana_kite::{ diff --git a/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs b/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs index 718d673cf..3c4f30ee4 100644 --- a/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs +++ b/tokens/nft-minter/anchor/programs/nft-minter/tests/test_nft_minter.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, }; diff --git a/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs b/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs index 2ad3145d8..4b235b388 100644 --- a/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs +++ b/tokens/nft-operations/anchor/programs/mint-nft/tests/test_nft_operations.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, }; diff --git a/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs b/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs index 3de594b71..e5e39b3a2 100644 --- a/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs +++ b/tokens/pda-mint-authority/anchor/programs/token-minter/tests/test_pda_mint.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, }; diff --git a/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs b/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs index 31862f680..6c55d7539 100644 --- a/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs +++ b/tokens/token-extensions/basics/anchor/programs/basics/tests/test_basics.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{get_token_extensions_account_address, TOKEN_EXTENSIONS_PROGRAM_ID}, diff --git a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs index e6ccb438f..00021a4df 100644 --- a/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs +++ b/tokens/token-extensions/cpi-guard/anchor/programs/cpi-guard/tests/test_cpi_guard.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs index 72b000241..7709c4fdb 100644 --- a/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs +++ b/tokens/token-extensions/default-account-state/anchor/programs/default-account-state/tests/test_default_account_state.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{mint_tokens_to_token_extensions_account, TOKEN_EXTENSIONS_PROGRAM_ID}, diff --git a/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs b/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs index 242d98446..fd4c903bf 100644 --- a/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs +++ b/tokens/token-extensions/group/anchor/programs/group/tests/test_group.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, diff --git a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs index 80dfe4725..365874594 100644 --- a/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs +++ b/tokens/token-extensions/immutable-owner/anchor/programs/immutable-owner/tests/test_immutable_owner.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{create_token_extensions_mint, TOKEN_EXTENSIONS_PROGRAM_ID}, diff --git a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs index 2b2b052a5..7eab29093 100644 --- a/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs +++ b/tokens/token-extensions/interest-bearing/anchor/programs/interest-bearing/tests/test_interest_bearing.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, diff --git a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs index be82cbcac..7f99ffbd7 100644 --- a/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs +++ b/tokens/token-extensions/memo-transfer/anchor/programs/memo-transfer/tests/test_memo_transfer.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs b/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs index 97d46cc61..cfc49a81a 100644 --- a/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs +++ b/tokens/token-extensions/metadata/anchor/programs/metadata/tests/test_metadata.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, diff --git a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs index 73c1843ed..f01296be7 100644 --- a/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs +++ b/tokens/token-extensions/mint-close-authority/anchor/programs/mint-close-authority/tests/test_mint_close_authority.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, diff --git a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs index 39cafc111..e2523d1f0 100644 --- a/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs +++ b/tokens/token-extensions/non-transferable/anchor/programs/non-transferable/tests/test_non_transferable.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs index 113d285b4..00288c545 100644 --- a/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs +++ b/tokens/token-extensions/permanent-delegate/anchor/programs/permanent-delegate/tests/test_permanent_delegate.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ assert_token_account_balance, create_wallet, send_transaction_from_instructions, token_extensions::{mint_tokens_to_token_extensions_account, TOKEN_EXTENSIONS_PROGRAM_ID}, diff --git a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs index 04a9bbb8d..95b419f03 100644 --- a/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs +++ b/tokens/token-extensions/transfer-fee/anchor/programs/transfer-fee/tests/test_transfer_fee.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index 9a024cd25..799122e24 100644 --- a/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/account-data-as-seed/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, solana_kite::{ create_wallet, send_transaction_from_instructions, diff --git a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs index 634b55360..a2e3dd260 100644 --- a/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs +++ b/tokens/token-extensions/transfer-hook/allow-block-list-token/anchor/programs/abl-token/tests/test_abl_token.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::TOKEN_EXTENSIONS_PROGRAM_ID, diff --git a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs index 8241a7020..2b466a986 100644 --- a/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs +++ b/tokens/token-extensions/transfer-hook/counter/anchor/programs/transfer-hook/tests/test_transfer_hook_counter.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, borsh::BorshDeserialize, solana_kite::{ create_wallet, send_transaction_from_instructions, diff --git a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index eeb17236d..9990b409a 100644 --- a/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/hello-world/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index 644d457b5..5ebe5774b 100644 --- a/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/transfer-cost/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs index 3ffd6c390..69857d21b 100644 --- a/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs +++ b/tokens/token-extensions/transfer-hook/transfer-switch/anchor/programs/transfer-switch/tests/test_transfer_switch.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs b/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs index f4021e5e8..4707cc605 100644 --- a/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs +++ b/tokens/token-extensions/transfer-hook/whitelist/anchor/programs/transfer-hook/tests/test_transfer_hook.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{ create_wallet, send_transaction_from_instructions, token_extensions::{ diff --git a/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs b/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs index bb8b02b9e..9d328e5a7 100644 --- a/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs +++ b/tokens/token-minter/anchor/programs/token-minter/tests/test_token_minter.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, }; diff --git a/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs b/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs index 5c73422e4..aedc89b7e 100644 --- a/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs +++ b/tokens/transfer-tokens/anchor/programs/transfer-tokens/tests/test_transfer_tokens.rs @@ -1,9 +1,9 @@ use { anchor_lang::{ - anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, solana_kite::{create_wallet, get_token_account_balance, send_transaction_from_instructions}, }; From 83871e26c421c655ef67f20befd794d62f99ba43 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 21:08:50 +0000 Subject: [PATCH 3/4] test: drop the braces on single-symbol harness imports rustfmt writes `use anchor_v2_testing::Signer;`, not `use anchor_v2_testing::{Signer};`. Three lending test files import only `Signer` from the harness and got the braced form from the migration. `cargo fmt --all --check` is clean across the workspace again. --- finance/lending/anchor/programs/lending/tests/test_interest.rs | 2 +- finance/lending/anchor/programs/lending/tests/test_rounding.rs | 2 +- finance/lending/anchor/programs/lending/tests/test_security.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/finance/lending/anchor/programs/lending/tests/test_interest.rs b/finance/lending/anchor/programs/lending/tests/test_interest.rs index 61afd65fe..864c9423f 100644 --- a/finance/lending/anchor/programs/lending/tests/test_interest.rs +++ b/finance/lending/anchor/programs/lending/tests/test_interest.rs @@ -1,6 +1,6 @@ mod common; -use anchor_v2_testing::{Signer}; +use anchor_v2_testing::Signer; use common::{ata, default_config, dollars, Env, SLOTS_PER_YEAR}; use lending::constants::FIXED_POINT_SCALE; diff --git a/finance/lending/anchor/programs/lending/tests/test_rounding.rs b/finance/lending/anchor/programs/lending/tests/test_rounding.rs index 1e12b4cb3..f135e4dbe 100644 --- a/finance/lending/anchor/programs/lending/tests/test_rounding.rs +++ b/finance/lending/anchor/programs/lending/tests/test_rounding.rs @@ -1,6 +1,6 @@ mod common; -use anchor_v2_testing::{Signer}; +use anchor_v2_testing::Signer; use lending::errors::LendingError; use common::{ata, default_config, dollars, Env}; diff --git a/finance/lending/anchor/programs/lending/tests/test_security.rs b/finance/lending/anchor/programs/lending/tests/test_security.rs index 9510ab335..f889196f0 100644 --- a/finance/lending/anchor/programs/lending/tests/test_security.rs +++ b/finance/lending/anchor/programs/lending/tests/test_security.rs @@ -1,6 +1,6 @@ mod common; -use anchor_v2_testing::{Signer}; +use anchor_v2_testing::Signer; use lending::errors::LendingError; use anchor_lang::{ From 8b5014b90a85ad17771ecf4888077cbac7bf4544 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 21 Aug 2026 21:25:29 +0000 Subject: [PATCH 4/4] ci: pass the IDL skip to anchor test, not just anchor build `anchor test` generates the IDL as well, so the `--no-idl` exemption added in #132 only covered half the problem: the eight projects it exempts got past `anchor build` and then failed at `anchor test` with the same upstream error, Error: missing field `variants` at line 1 column 6579 which is anchor#4947, `#[derive(IdlType)]` emitting `fields` where the IDL spec requires `variants` for enums. `betting-market` hit this on the harness-migration PR. I have not established why the same call sequence passed on the `main` run that introduced the skip; the build cache is the likeliest difference, since this branch touches every program's manifest and so cannot reuse it. Either way the exemption belongs on both commands, and adding it cannot break a project that was already passing. Removed together with the rest of the workaround when an Anchor release carrying the fix ships. --- .github/workflows/anchor.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/anchor.yml b/.github/workflows/anchor.yml index d1e039bcd..bd9a74c5f 100644 --- a/.github/workflows/anchor.yml +++ b/.github/workflows/anchor.yml @@ -309,8 +309,10 @@ jobs: return 1 fi - # Run anchor test - if ! anchor test; then + # Run anchor test. It regenerates the IDL too, so the skip above + # has to apply here as well or the projects it exempts fail at the + # test step instead of the build step. + if ! anchor test $idl_flag; then echo "::error::anchor test failed for $project" echo "$project: anchor test failed" >> $GITHUB_WORKSPACE/failed_projects.txt rm -rf target node_modules