1

I want to use solana-program-test crate to do some integrated tests.

I've read the code of some sample Solana programs in the official solana-program-library repo on GitHub. Inside, there's an example program called transfer-tokens, that demonstrates how to perform a CPI to Token Program to transfer SPL tokens.

The Rust test file is here. I'm wondering why the Token Program isn't added to the test environment by calling program_test.add_program(). In my opinion, the Token Program has no difference with the custom sample program, in that both 2 programs are not native programs like System Program. The Token Program is but a normal program that is implemented by Solana Dev Team. Why is the custom program necessary to be added (here it's added in ProgramTest::new() that calls add_program() inside), while the Token Program is not explicitly added?

Also, from the solana-program-test crate's doc, I learn that I can specify the fixtures of the test environment. I'm wondering if there's a more detailed and official doc that describes how fixtures work in solana-program-test crate? The Rust doc only introduces the fixtures with no more than 100 words.

1 Answer 1

3

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/master/program-test/src/programs.rs, and they include:

  • spl-token
  • spl-token-2022
  • spl-memo-1.0
  • spl-memo-3.0
  • spl-associated-token-account

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.