Skip to content

Commit

Permalink
do not filter map resulting accounts (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Dec 4, 2024
1 parent 1dd4692 commit aa2afc9
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ impl Mollusk {

let resulting_accounts: Vec<(Pubkey, AccountSharedData)> = accounts
.iter()
.filter_map(|(pubkey, _)| {
.map(|(pubkey, account)| {
transaction_context
.find_index_of_account(pubkey)
.map(|index| {
let account = transaction_context.get_account_at_index(index).unwrap();
(*pubkey, account.take())
let resulting_account =
transaction_context.get_account_at_index(index).unwrap();
(*pubkey, resulting_account.take())
})
.unwrap_or((*pubkey, account.clone()))
})
.collect();

Expand Down Expand Up @@ -234,17 +236,8 @@ impl Mollusk {
result.compute_units_consumed += this_result.compute_units_consumed;
result.execution_time += this_result.execution_time;
result.program_result = this_result.program_result;
for resulting_account in this_result.resulting_accounts.into_iter() {
if let Some(pos) = result
.resulting_accounts
.iter()
.position(|(key, _)| key == &resulting_account.0)
{
result.resulting_accounts[pos].1 = resulting_account.1;
} else {
result.resulting_accounts.push(resulting_account);
}
}
result.raw_result = this_result.raw_result;
result.resulting_accounts = this_result.resulting_accounts;

if result.program_result.is_err() {
break;
Expand Down

0 comments on commit aa2afc9

Please sign in to comment.