I didn't find any relevant documentation on how does solana_program_test works: does it actually start the sandbox on localnet or it uses some emulated environment?

Any context about it is appreciated.

1 Answer 1


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 explicitly for Solana programs. This framework is centered around the BanksClient. It simulates a Solana bank’s operations, enabling developers to deploy, interact with, and assess the behavior of their programs under test conditions that mimic mainnet, similar to Bankrun. Complimenting the BanksClient is the ProgramTest struct, a utility for initializing the test environment. That is, it facilitates the development of specified programs and the setup of necessary accounts. Additional structs like BanksTransactionResultWithMetadata, InvokeContext, and ProgramTestContext offer rich insights and context for transactions processed during testing, enhancing the overall debugging and verification process.

To streamline local development and testing, solana-program-test automatically preloads several programs:

SPL Token (and its 2022 version) SPL Memo (versions 1.0 and 3.0) SPL Associated Token Account These preloaded programs provide a quicker and more focused testing setup as they do not need to worry about manually setting up these common programs.

The Marginfi GitHub repository has several great examples of implementing solana-program-test for production-ready code. Bonfida’s development guide also has a great walkthrough on writing integration tests using the solana-program-test framework.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.