Skip to main content
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 ...
McBain's user avatar
  • 5,384
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 ...
Jonas H.'s user avatar
  • 7,209
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/...
Jon C's user avatar
  • 19.6k
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
hrs8's user avatar
  • 146
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 ...
Jonas H.'s user avatar
  • 7,209
2 votes

Print in Solana Playground

Try msg!("asdf"); or msg!("some var: {:?}", some_var) to print a variable to the logs.
Whiteseal's user avatar
  • 3,597
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 ...
chalda's user avatar
  • 1,657
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 ...
Jonas H.'s user avatar
  • 7,209
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,...
C.OG's user avatar
  • 2,907
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,...
Jon C's user avatar
  • 19.6k
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 ...
Jon C's user avatar
  • 19.6k
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/...
Juan Marchetto's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible