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.