Cleanup: TransactionContext (#22910)

* Adds BorrowedAccount::check_sysvar().

* Adds BorrowedAccount::get_data_mut().

* Implements account resizing in BorrowedAccount.

* Exposes is_signer() and is_writable() in InstructionContext.

* Removes AccountMeta and get_instruction_accounts_metas().

* Makes throwing errors in BorrowedAccount optional.

* Removes result return values from BorrowedAccount.
This commit is contained in:
Alexander Meißner
2022-02-03 17:19:42 +01:00
committed by GitHub
parent c16cf9cf8a
commit 660f6981c6
6 changed files with 89 additions and 116 deletions

View File

@ -1283,13 +1283,13 @@ mod tests {
MockInstruction::NoopFail => return Err(InstructionError::GenericError),
MockInstruction::ModifyOwned => instruction_context
.try_borrow_instruction_account(transaction_context, 0)?
.set_data(&[1])?,
.set_data(&[1]),
MockInstruction::ModifyNotOwned => instruction_context
.try_borrow_instruction_account(transaction_context, 1)?
.set_data(&[1])?,
.set_data(&[1]),
MockInstruction::ModifyReadonly => instruction_context
.try_borrow_instruction_account(transaction_context, 2)?
.set_data(&[1])?,
.set_data(&[1]),
MockInstruction::ConsumeComputeUnits {
compute_units_to_consume,
desired_result,
@ -1303,7 +1303,7 @@ mod tests {
}
MockInstruction::Resize { new_len } => instruction_context
.try_borrow_instruction_account(transaction_context, 0)?
.set_data(&vec![0; new_len])?,
.set_data(&vec![0; new_len]),
}
} else {
return Err(InstructionError::InvalidInstructionData);