We need program restart logic since we're firing 300+ ix and the program_context seems to melt down every couple of hundred ix. It basically just picks up the account state where it left off and restarts the client
(
accounts_vector: &mut Vec<(&Pubkey, usize, Option<Vec<u8>>)>,
token_accounts: Option<&mut Vec<(&Pubkey, &Pubkey, u64)>>,
program_id: &Pubkey,
signer_pubkey: &Pubkey,
| 340 | // the program_context seems to melt down every couple of hundred ix. |
| 341 | // It basically just picks up the account state where it left off and restarts the client |
| 342 | pub async fn restart_program( |
| 343 | accounts_vector: &mut Vec<(&Pubkey, usize, Option<Vec<u8>>)>, |
| 344 | token_accounts: Option<&mut Vec<(&Pubkey, &Pubkey, u64)>>, |
| 345 | program_id: &Pubkey, |
| 346 | signer_pubkey: &Pubkey, |
| 347 | program_context: &mut ProgramTestContext, |
| 348 | ) -> ProgramTestContext { |
| 349 | for (pubkey, _, current_data) in accounts_vector.iter_mut() { |
| 350 | let account = program_context |
| 351 | .banks_client |
| 352 | .get_account(**pubkey) |
| 353 | .await |
| 354 | .expect("get_account") |
| 355 | .unwrap(); |
| 356 | *current_data = Some(account.data.to_vec()); |
| 357 | } |
| 358 | let program_context_new = create_and_start_program_var( |
| 359 | &accounts_vector, |
| 360 | token_accounts, |
| 361 | &program_id, |
| 362 | &signer_pubkey, |
| 363 | ) |
| 364 | .await; |
| 365 | |
| 366 | program_context_new |
| 367 | } |
| 368 | } |
no test coverage detected