Ackee-Blockchain / trident

Rust-based framework to Fuzz and Integration test Solana programs to help you ship secure code.
https://ackee.xyz/
MIT License
185 stars 18 forks source link

✨ Allow direct accounts manipulation #142

Closed Ikrk closed 5 months ago

Ikrk commented 5 months ago

This PR extends the FuzzClient trait and the functionality of AccountsStorage in order to have more flexibility to create and store an arbitrary account. This removes the previous limitation that only basic accounts operations were possible.

Now, one can create and store any kind of account. For example:

let reserve_pda = fuzz_accounts .reserve_pda .storage() .entry(self.accounts.reserve_pda) .or_insert_with(|| { let seeds = &[b"some-seeds"]; let pda = Pubkey::find_program_address(seeds, &my_program::id()).0; let account = AccountSharedData::new_data_with_space::<[u8; 0]>( rent_exempt_for_token_acc, &[], 0, &SYSTEM_PROGRAM_ID, ) .unwrap(); client.set_account_custom(&pda, &account); let vec_of_seeds: Vec<Vec> = seeds.iter().map(|&seed| seed.to_vec()).collect(); PdaStore { pubkey: pda, seeds: vec_of_seeds, } }) .pubkey();