3 releases
0.0.1-alpha.3 | Feb 24, 2022 |
---|---|
0.0.1-alpha.2 | Feb 10, 2022 |
0.0.1-alpha.1 | Feb 1, 2022 |
#341 in #programs
Used in agsol-gold-contract
17KB
308 lines
Convenience data structures and methods for interacting with the Solana program test context.
Examples
Assume there's a Solana program with a processor of the form
// foo_program::processor
fn processor(
id: &Pubkey,
accounts: &[AccountInfo],
data: &[u8]
) -> Result<(), ProgramError>
{
// snip
Ok(())
}
It can be loaded into the testbench as
use agsol_testbench::{Testbench, TestbenchProgram, TestUser};
use solana_program_test::processor;
// program `foo` with program pubkey FOO_PROGRAM_ID
let program_from_processor = TestbenchProgram {
name: "foo_bpf_program",
id: FOO_PROGRAM_ID,
process_instruction: processor!(foo_program::processor),
};
// program `bar` with program pubkey BAR_PROGRAM_ID
let program_from_binary = TestbenchProgram {
name: "bar_bpf_program",
id: BAR_PROGRAM_ID,
process_instruction: None,
};
// load programs into the test context
let mut testbench = Testbench::new(&[program_from_processor, program_from_binary]).await.unwrap();
// create a test user with an airdrop
let test_user = TestUser::new(&mut testbench).await.unwrap().unwrap();
Dependencies
~90MB
~1.5M SLoC