Skip to content

Commit

Permalink
only update accounts on success
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Jan 13, 2025
1 parent ae195a1 commit bbfef82
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions harness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,22 +219,26 @@ impl Mollusk {

let return_data = transaction_context.get_return_data().1.to_vec();

let resulting_accounts: Vec<(Pubkey, Account)> = accounts
.iter()
.map(|(pubkey, account)| {
transaction_context
.find_index_of_account(pubkey)
.map(|index| {
let resulting_account = transaction_context
.get_account_at_index(index)
.unwrap()
.take()
.into();
(*pubkey, resulting_account)
})
.unwrap_or((*pubkey, account.clone()))
})
.collect();
let resulting_accounts: Vec<(Pubkey, Account)> = if invoke_result.is_ok() {
accounts
.iter()
.map(|(pubkey, account)| {
transaction_context
.find_index_of_account(pubkey)
.map(|index| {
let resulting_account = transaction_context
.get_account_at_index(index)
.unwrap()
.take()
.into();
(*pubkey, resulting_account)
})
.unwrap_or((*pubkey, account.clone()))
})
.collect()
} else {
accounts.to_vec()
};

InstructionResult {
compute_units_consumed,
Expand Down

0 comments on commit bbfef82

Please sign in to comment.