Refactor: Removes Rc from Refcell<AccountSharedData> in the program-runtime (#21927)

* Removes Rc from Rc<RefCell<AccountSharedData>> in the program-runtime.

* Adjusts tests in bpf_loader, system_instruction_processor, config_processor, vote_instruction and stake_instruction
This commit is contained in:
Alexander Meißner
2021-12-17 14:01:12 +01:00
committed by GitHub
parent 56ec5245cc
commit 66fa8f9667
11 changed files with 2907 additions and 2342 deletions

View File

@@ -202,19 +202,19 @@ mod tests {
process_instruction: mock_system_process_instruction,
}];
let program_account = Rc::new(RefCell::new(create_loadable_account_for_test(
"mock_system_program",
)));
let accounts = vec![
(
solana_sdk::pubkey::new_rand(),
AccountSharedData::new_ref(100, 1, &mock_system_program_id),
RefCell::new(AccountSharedData::new(100, 1, &mock_system_program_id)),
),
(
solana_sdk::pubkey::new_rand(),
AccountSharedData::new_ref(0, 1, &mock_system_program_id),
RefCell::new(AccountSharedData::new(0, 1, &mock_system_program_id)),
),
(
mock_system_program_id,
RefCell::new(create_loadable_account_for_test("mock_system_program")),
),
(mock_system_program_id, program_account),
];
let program_indices = vec![vec![2]];
@@ -406,19 +406,19 @@ mod tests {
process_instruction: mock_system_process_instruction,
}];
let program_account = Rc::new(RefCell::new(create_loadable_account_for_test(
"mock_system_program",
)));
let accounts = vec![
(
solana_sdk::pubkey::new_rand(),
AccountSharedData::new_ref(100, 1, &mock_program_id),
RefCell::new(AccountSharedData::new(100, 1, &mock_program_id)),
),
(
solana_sdk::pubkey::new_rand(),
AccountSharedData::new_ref(0, 1, &mock_program_id),
RefCell::new(AccountSharedData::new(0, 1, &mock_program_id)),
),
(
mock_program_id,
RefCell::new(create_loadable_account_for_test("mock_system_program")),
),
(mock_program_id, program_account),
];
let program_indices = vec![vec![2]];
@@ -539,13 +539,13 @@ mod tests {
process_instruction: mock_process_instruction,
}];
let secp256k1_account = AccountSharedData::new_ref(1, 0, &native_loader::id());
secp256k1_account.borrow_mut().set_executable(true);
let mock_program_account = AccountSharedData::new_ref(1, 0, &native_loader::id());
mock_program_account.borrow_mut().set_executable(true);
let mut secp256k1_account = AccountSharedData::new(1, 0, &native_loader::id());
secp256k1_account.set_executable(true);
let mut mock_program_account = AccountSharedData::new(1, 0, &native_loader::id());
mock_program_account.set_executable(true);
let accounts = vec![
(secp256k1_program::id(), secp256k1_account),
(mock_program_id, mock_program_account),
(secp256k1_program::id(), RefCell::new(secp256k1_account)),
(mock_program_id, RefCell::new(mock_program_account)),
];
let message = Message::new(