Courses

Testing and Debugging Solana Programs
Solana · Chapter 12

Testing and Debugging Solana Programs

Testing checks whether the program follows its rules before people rely on it. Start with a local test environment, where you can reset state and repeat experiments.

The basics

  • Check a successful action and read the stored data afterward.
  • Test failures too: missing signatures, invalid accounts and unauthorized updates.
  • Read transaction logs to find the failing instruction. Reproduce one problem at a time rather than changing several things at once.

Try it yourself

In your Anchor project, run the generated tests with anchor test after local setup. Add an assertion for the expected result, then deliberately change that expectation and see the test fail.

Read more in the official documentation

@ Daniel Burlacu