Skip to main content

Questions tagged [solana-program-test]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
1 answer
76 views

Changes to runtime's LoadedPrograms between 1.17.6 and versions after in the ProgramTest context

Can someone summarize the changes to how LoadedPrograms work between version 1.17.6 and versions after? The changes have broken my ProgramTest setup and I would like to know if I can recreate it after ...
billy's user avatar
  • 352
2 votes
1 answer
54 views

How does solana_program_test work?

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....
solanauser67's user avatar
2 votes
1 answer
271 views

Print in Solana Playground

I want to debug my program in Solana Playground. I am using the print function to get logs. The containing function is running but not producing any logs. Attaching a screenshot below.
shubhanshuk.sarkar's user avatar
2 votes
0 answers
52 views

Testing Solana Programs

So I'm looking for a way to write solana smart contract test cases, which crates are used for doing so? Example test cases written in rust would be of great help! I can write smart contracts using ...
Muhammad Ali's user avatar
1 vote
1 answer
52 views

With solana-program-test crate, what accounts/programs will be included in the environment by default when starting test?

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 ...
Yan's user avatar
  • 377
1 vote
3 answers
737 views

Failing to create associated token account in rust tests. It says insufficient account keys for instruction

https://github.com/SushantChandla/test-mint-bug/blob/main/programs/mint-bug/tests/mint.rs I am trying to create an associated token account please have a look at the github file. The error I get is ...
Sushant Chandla's user avatar
1 vote
1 answer
515 views

Testing Anchor program with solana-program-test crate

I was trying to test my anchor program with rust tests. Test written in Typescript are working fine. I am getting with cargo test: note: run with `RUST_BACKTRACE=1` environment variable to display a ...
Sushant Chandla's user avatar
1 vote
1 answer
25 views

Why `ProgramTestContext::set_account` with a program account caches the first call?

ProgramTestContext::set_account caches the first call for a program account, not allowing it to the updated again. I tried updating a program account in 3 ways: by using a simple account with program ...
asdragnea's user avatar
1 vote
1 answer
112 views

Solana program test coverage

Is there any tool to measure test coverage of test written in rust with solana-program-test crate?
Sushant Chandla's user avatar
1 vote
1 answer
22 views

How to use spl_token account with solana-program-test crate?

I am trying to write a test with the solana-program-test crate for a solana program. This program makes a CPI to a token program: let ix = Instruction { program_id: *token_program.key, ...
S.Rivas's user avatar
  • 11
1 vote
0 answers
17 views

Failed to send transaction: Transaction simulation failed: Error processing Instruction 0: incorrect program id for instruction

In the const sx = await sendAndConfirmTransaction i am getting error const { Connection, Keypair, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionInstruction, ...
Aditya's user avatar
  • 157
1 vote
0 answers
45 views

Solana Program Test with installed geyser plugin

For the program I'm writing I need to "fast forward" the validator clock for some of my tests. I noticed that warp_slot is available in solana-program-test however I can't seem to find or ...
Anthony Anderson's user avatar
1 vote
0 answers
36 views

Solana 1.17+, what processor should be used when instantiating ProgramTest::new()?

I recently upgraded from Solana 1.14 to 1.17.22 and I'm not able to write rust tests that way I've previously been able to. Specifically, previously, when instantiating ProgramTest::new I've typically ...
Ted's user avatar
  • 11
1 vote
1 answer
59 views

BanksClient: should I prefer `process_transaction_with_metadata` over `process_transaction?`

I've noticed that process_transaction (and process_transaction_with_preflight_and_commitment) hangs when a program is missing from BanksServer or when it encounters an AccountInUse error. It probably ...
KevinH's user avatar
  • 422
0 votes
1 answer
19 views

Is it possible to add spl_token_2022 program to ProgramTest in solana_program_test?

I want to write integration test for the transfer hook program by not calling the program directly, but calling spl_token_2022 program (with configured transfer hook) that will trigger transfer hook ...
solanauser67's user avatar
0 votes
1 answer
40 views

Error while trying to use solana_program_test?

i am getting "RpcError(DeadlineExceeded)" all time.
pooria sarkhan's user avatar
0 votes
0 answers
32 views

How to add AddressLookupTab1e1111111111111111111111111 to ProgramTest

I am getting this error : [2024-01-07T15:07:17.830011345Z DEBUG solana_runtime::message_processor::stable_log] Program AddressLookupTab1e1111111111111111111111111 invoke [1] [2024-01-07T15:07:17....
datben's user avatar
  • 1
0 votes
0 answers
48 views

Implement get_program_accounts using BanksClient

BanksClient doesn't have a get_program_accounts method. Is there a way to mimic it?
KevinH's user avatar
  • 422
0 votes
0 answers
82 views

Solana program tests are not running in isolated environment

I am running tests with cargo test-sbf. We have a Global Program State that needs to be created only once the lifetime of program. All the program tests are isolated that means I have to do it in all ...
Sushant Chandla's user avatar
0 votes
2 answers
74 views

Impossible to add multiple programs to ProgramTest?

fn setup(program_id: &Pubkey, other_program_id: &Pubkey) -> ProgramTest { let mut program_test = ProgramTest::new( "program", *program_id, processor!(...
Unknown's user avatar
0 votes
1 answer
71 views

Is it possible to do getProgramAccounts using ProgramTestContext?

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 ...
itsfarseen's user avatar