AccountSharedData.set_data (#15781)
* account.set_data and resize_data * remove data_resize
This commit is contained in:
committed by
GitHub
parent
e1ceb430e3
commit
3419a5446e
@ -941,7 +941,7 @@ mod tests {
|
||||
// Case: Write bytes to an offset
|
||||
#[allow(unused_mut)]
|
||||
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, true, &program_account)];
|
||||
keyed_accounts[0].account.borrow_mut().data = vec![0; 6];
|
||||
keyed_accounts[0].account.borrow_mut().set_data(vec![0; 6]);
|
||||
assert_eq!(
|
||||
Ok(()),
|
||||
process_instruction(
|
||||
@ -959,7 +959,7 @@ mod tests {
|
||||
// Case: Overflow
|
||||
#[allow(unused_mut)]
|
||||
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, true, &program_account)];
|
||||
keyed_accounts[0].account.borrow_mut().data = vec![0; 5];
|
||||
keyed_accounts[0].account.borrow_mut().set_data(vec![0; 5]);
|
||||
assert_eq!(
|
||||
Err(InstructionError::AccountDataTooSmall),
|
||||
process_instruction(
|
||||
@ -981,7 +981,7 @@ mod tests {
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
let program_account =
|
||||
AccountSharedData::new_ref(rent.minimum_balance(elf.len()), 0, &program_id);
|
||||
program_account.borrow_mut().data = elf;
|
||||
program_account.borrow_mut().set_data(elf);
|
||||
let keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)];
|
||||
let instruction_data = bincode::serialize(&LoaderInstruction::Finalize).unwrap();
|
||||
|
||||
@ -1046,7 +1046,7 @@ mod tests {
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
let program_account = AccountSharedData::new_ref(1, 0, &program_id);
|
||||
program_account.borrow_mut().data = elf;
|
||||
program_account.borrow_mut().set_data(elf);
|
||||
program_account.borrow_mut().executable = true;
|
||||
|
||||
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)];
|
||||
@ -1141,7 +1141,7 @@ mod tests {
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
let program_account = AccountSharedData::new_ref(1, 0, &program_id);
|
||||
program_account.borrow_mut().data = elf;
|
||||
program_account.borrow_mut().set_data(elf);
|
||||
program_account.borrow_mut().executable = true;
|
||||
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)];
|
||||
|
||||
@ -1185,7 +1185,7 @@ mod tests {
|
||||
let mut elf = Vec::new();
|
||||
file.read_to_end(&mut elf).unwrap();
|
||||
let program_account = AccountSharedData::new_ref(1, 0, &program_id);
|
||||
program_account.borrow_mut().data = elf;
|
||||
program_account.borrow_mut().set_data(elf);
|
||||
program_account.borrow_mut().executable = true;
|
||||
let mut keyed_accounts = vec![KeyedAccount::new(&program_key, false, &program_account)];
|
||||
|
||||
@ -3247,7 +3247,7 @@ mod tests {
|
||||
0..255,
|
||||
|bytes: &mut [u8]| {
|
||||
let program_account = AccountSharedData::new_ref(1, 0, &program_id);
|
||||
program_account.borrow_mut().data = bytes.to_vec();
|
||||
program_account.borrow_mut().set_data(bytes.to_vec());
|
||||
program_account.borrow_mut().executable = true;
|
||||
|
||||
let parameter_account = AccountSharedData::new_ref(1, 0, &program_id);
|
||||
|
Reference in New Issue
Block a user