When fuzz testing outside of bpf-land (i.e. the target os is not solana), cpis will fall back to crate-level program stubs, and we can invoke spl token instructions with the handy processor:
pub struct TestSyscallStubs {
pub unix_timestamp: Option<i64>,
}
impl program_stubs::SyscallStubs for TestSyscallStubs {
fn sol_invoke_signed(
&self,
instruction: &Instruction,
account_infos: &[AccountInfo],
signers_seeds: &[&[&[u8]]],
) -> ProgramResult {
let mut new_account_infos = vec![];
// Fill ix account metas as needed...
if instruction.program_id == spl_token::ID {
spl_token::processor::Processor::process(
&instruction.program_id,
&new_account_infos,
&instruction.data,
)
} else if instruction.program_id == system_program::ID {
// TODO
}
}
}
How can we do the same kind of thing for system program instructions like a SOL transfer?