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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/anchor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions basics/close-account/anchor/programs/close-account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions basics/counter/anchor/programs/counter_anchor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions basics/cross-program-invocation/anchor/programs/hand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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");
Expand Down
15 changes: 12 additions & 3 deletions basics/cross-program-invocation/anchor/programs/lever/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions basics/favorites/anchor/programs/favorites/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
Loading
Loading