4
votes
Accepted
Using solana-program-test, but stuck at initialize instruction
This is a known issue between anchor and solana-test. At the moment, the recommended workaround is to use cargo test-sbf instead of cargo test (more info on why this works here.) Depending on your ...
3
votes
Accepted
How does solana_program_test work?
Copied from this great testing guide from helius: https://www.helius.dev/blog/a-guide-to-testing-solana-programs
The solana-program-test crate provides a Rust-based testing framework designed ...
3
votes
Accepted
With solana-program-test crate, what accounts/programs will be included in the environment by default when starting test?
solana-program-test adds a few programs by default to help with local development and so that devs don't need as many fixtures.
You can find those programs at https://github.com/anza-xyz/agave/blob/...
3
votes
Accepted
Testing Anchor program with solana-program-test crate
Try running the test with cargo test-bpf and specify the tests. So command is:
cargo test-bpf --test initialize -- testing_iniitalize
2
votes
Accepted
What is a consistent way to fund(airdrop) to new accounts on devnet in your Anchor test program?
You could use always the same keypair that already has sol.
For that you can for example use the Solana Helpers:
https://github.com/solana-developers/helpers/blob/main/src/lib/keypair.ts
If you need a ...
2
votes
Print in Solana Playground
Try msg!("asdf"); or msg!("some var: {:?}", some_var) to print a variable to the logs.
2
votes
Accepted
Failing to create associated token account in rust tests. It says insufficient account keys for instruction
I hit the same issue and found there is a difference in behaviour of solana validator versions.
I worked against test validator in version 1.9.29 (developing on localhost). I was using the version of ...
1
vote
need a better way to analyse tests working for transactions that exceed timeout
Im guessing whats happening here is that you have global
let context; and let provider: BankrunProvider;
And since jest tests can also run in parallel the provider gets killed during the tests or ...
1
vote
Failing to create associated token account in rust tests. It says insufficient account keys for instruction
You're missing the token_program_id
The create_associated_token_account takes four parameters.
pub fn create_associated_token_account(
funding_address: &Pubkey,
wallet_address: &Pubkey,...
1
vote
Why `ProgramTestContext::set_account` with a program account caches the first call?
Normally, you should be able to update the second one to update the program account.
As you noticed, there is some caching involved. The program cache, even in test environments, lasts at least 1 slot,...
1
vote
Accepted
Impossible to add multiple programs to ProgramTest?
The error "multiple definition of entrypoint" means that the symbol entrypoint exists multiple times in your package. This happens when one of the crates that your program depends on also ...
1
vote
Solana program test coverage
No there is not, related info:
https://crates.io/crates/solana-program-test
https://docs.rs/solana-program-test/1.15.2/solana_program_test/
https://github.com/solana-labs/solana/tree/...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
solana-program-test × 31solana-program × 9
rust × 7
testing × 7
anchor × 6
anchor-test × 4
solana-sdk × 3
spl-token × 2
solana-test-validator × 2
devnet × 2
program-test × 2
bankclient × 2
anchor-lang × 2
solana-client × 2
spl-associated-token-account × 2
anchor-client × 1
cpi × 1
spl × 1
getprogramaccounts × 1
solana-cli × 1
geyser × 1
cargo × 1
logs × 1
runtime × 1
anchor-accounts × 1