I am trying to speed up my tests by switching from using a local test validator to using ProgramTestContext.
This will let me execute multiple tests in parallel where each one has its own instance of ProgramTestContext.
While I was rewriting the tests to use ProgramTestContext, I noticed that there is no way to call getProgramAccounts. I searched Solana Rust docs and the API docs in docs.rs to no avail.

Is it not possible to do getProgramAccounts when testing without using a local validator?

  • You're correct that the BanksClient exposed by ProgramTestContext doesn't allow you to call get_program_accounts. You'll have to fetch the accounts one by one, or put in a PR to BanksClient to implement get_program_accounts.
    – Jon C
    Commented Dec 19, 2022 at 17:52

1 Answer 1


yes it is possible to get accounts that are associated with a program, I would say the ProgramTestContext is a tool on the Solana SDK that allows you to test smart contracts in a Test Environment...so to get the associated accounts you can use the get_program_accounts function.

  • I can't find get_program_accounts impl'd on the ProgramTestContext or BanksClient (ProgramTestContext.client). I tried looking in docs.rs
    – itsfarseen
    Commented Dec 19, 2022 at 7:35

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.