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 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..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 @@ -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, }; /// 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..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 @@ -3,16 +3,14 @@ use { solana_program::{instruction::Instruction, system_instruction}, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,15 +3,13 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,16 +3,14 @@ use { solana_program::{instruction::Instruction, rent::Rent}, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -2,10 +2,8 @@ use { anchor_lang::{ solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..48b64f75a 100644 --- a/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs +++ b/basics/favorites/anchor/programs/favorites/tests/test_favorites.rs @@ -3,9 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, + anchor_v2_testing::{LiteSVM, Signer}, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; struct FavoritesData { @@ -51,9 +50,9 @@ 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 = 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..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 @@ -3,15 +3,13 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -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) { +fn setup() -> (LiteSVM, anchor_v2_testing::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..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 @@ -3,15 +3,14 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{LiteSVM, Signer}, borsh::BorshDeserialize, - litesvm::LiteSVM, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; -fn setup() -> (LiteSVM, solana_keypair::Keypair) { +fn setup() -> (LiteSVM, anchor_v2_testing::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..acd4fb66a 100644 --- a/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs +++ b/basics/pyth/anchor/programs/pythexample/tests/test_pyth.rs @@ -2,13 +2,11 @@ use { anchor_lang::{ solana_program::instruction::Instruction, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, + 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, - solana_keypair::Keypair, solana_kite::{create_wallet, send_transaction_from_instructions}, - solana_signer::Signer, }; /// The `publish_time` baked into the mock price update below. @@ -83,9 +81,9 @@ 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 = 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..2ad901bf5 100644 --- a/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.rs +++ b/basics/realloc/anchor/programs/anchor-realloc/tests/test_realloc.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, }; #[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..deb13f057 100644 --- a/basics/rent/anchor/programs/rent-example/tests/test_rent.rs +++ b/basics/rent/anchor/programs/rent-example/tests/test_rent.rs @@ -2,16 +2,14 @@ use { anchor_lang::{ solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..f62972024 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) { +fn setup() -> (LiteSVM, anchor_v2_testing::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(); @@ -15,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, @@ -39,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, @@ -61,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/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..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 @@ -2,10 +2,8 @@ use { anchor_lang::{ solana_program::instruction::Instruction, system_program, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,15 +3,13 @@ use { solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..6f02572da 100644 --- a/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs +++ b/finance/escrow/anchor/programs/escrow/tests/test_escrow.rs @@ -3,14 +3,12 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + 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, 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..864c9423f 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..f135e4dbe 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..f889196f0 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..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 @@ -23,14 +23,12 @@ use { InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + 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, 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..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 @@ -3,15 +3,13 @@ use { solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,18 +3,16 @@ use { solana_program::instruction::Instruction, system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..0bfa52d28 100644 --- a/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs +++ b/finance/token-fundraiser/anchor/programs/fundraiser/tests/test_fundraiser.rs @@ -3,18 +3,16 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -5,14 +5,12 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + 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, 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..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 @@ -4,17 +4,15 @@ use { system_program, AccountDeserialize, Address, InstructionData, ToAccountMetas, }, anchor_spl::token::spl_token, - litesvm::LiteSVM, + 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, - 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,16 +3,14 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,13 +3,11 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + 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}, }, - 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,13 +3,11 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + 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}, }, - 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..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 @@ -3,18 +3,17 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, + anchor_v2_testing::{LiteSVM, Signer}, 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..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 @@ -3,13 +3,11 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,18 +3,16 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,18 +3,16 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,18 +3,16 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,18 +3,16 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + 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}, }, - 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::{AccountMeta, Instruction}, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,9 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,18 +3,16 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,9 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,8 +3,7 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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..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 @@ -3,10 +3,8 @@ use { solana_program::instruction::Instruction, system_program, Address, InstructionData, ToAccountMetas, }, - litesvm::LiteSVM, - solana_keypair::Keypair, + anchor_v2_testing::{Keypair, LiteSVM, Signer}, 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();