Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions program-runtime/src/invoke_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ mod tests {
.unwrap();
invoke_context.push().unwrap();
let inner_instruction =
Instruction::new_with_bincode(callee_program_id, &instruction, metas.clone());
Instruction::new_with_bincode(callee_program_id, &instruction, metas);
let result = invoke_context
.native_invoke(inner_instruction, &[])
.and(invoke_context.pop());
Expand Down Expand Up @@ -1308,7 +1308,7 @@ mod tests {
compute_units_to_consume,
desired_result: expected_result.clone(),
},
metas.clone(),
metas,
);
invoke_context
.prepare_next_instruction(inner_instruction, &[])
Expand Down
5 changes: 4 additions & 1 deletion program-runtime/src/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,10 @@ mod tests {
.store::<u32>(0, account_start_offsets[0])
.unwrap_err();

// Writing to shared writable account makes it unique (CoW logic)
// Writing to shared writable account makes it unique (CoW logic.)
// It has been previously been made non-unique at the beginning of
// the test through a clone.
let _shared_account_ref = shared_account;
assert!(
transaction_context
.accounts()
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/bank/accounts_lt_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ mod tests {
.collect();

let mut expected_delta_lt_hash = LtHash::identity();
let mut expected_accounts_lt_hash = prev_accounts_lt_hash.clone();
let mut expected_accounts_lt_hash = prev_accounts_lt_hash;
let mut updater =
|address: &Pubkey, prev: Option<AccountSharedData>, post: Option<AccountSharedData>| {
// if there was an alive account, mix out
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/bank/partitioned_epoch_rewards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ mod tests {
} = create_genesis_config_with_vote_accounts(1_000_000_000, &validator_keypairs, stakes);
genesis_config.epoch_schedule = EpochSchedule::new(SLOTS_PER_EPOCH);

let mut accounts_db_config: AccountsDbConfig = ACCOUNTS_DB_CONFIG_FOR_TESTING.clone();
let mut accounts_db_config: AccountsDbConfig = ACCOUNTS_DB_CONFIG_FOR_TESTING;
accounts_db_config.partitioned_epoch_rewards_config =
PartitionedEpochRewardsConfig::new_for_test(stake_account_stores_per_block);

Expand Down Expand Up @@ -704,7 +704,7 @@ mod tests {
genesis_config.epoch_schedule = EpochSchedule::custom(32, 32, false);

// Config stake reward distribution to be 10 per block
let mut accounts_db_config: AccountsDbConfig = ACCOUNTS_DB_CONFIG_FOR_TESTING.clone();
let mut accounts_db_config: AccountsDbConfig = ACCOUNTS_DB_CONFIG_FOR_TESTING;
accounts_db_config.partitioned_epoch_rewards_config =
PartitionedEpochRewardsConfig::new_for_test(10);

Expand Down
27 changes: 9 additions & 18 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6033,11 +6033,7 @@ fn test_bank_load_program() {
let instruction = Instruction::new_with_bytes(program_key, &[], Vec::new());
let invocation_message = Message::new(&[instruction], Some(&mint_keypair.pubkey()));
let binding = mint_keypair.insecure_clone();
let transaction = Transaction::new(
&[&binding],
invocation_message.clone(),
bank.last_blockhash(),
);
let transaction = Transaction::new(&[&binding], invocation_message, bank.last_blockhash());
assert!(bank.process_transaction(&transaction).is_ok());

{
Expand Down Expand Up @@ -6104,7 +6100,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
// after creating the program, the new transaction created below with the
// same `invocation_message` as above doesn't return `AlreadyProcessed` when
// processed.
goto_end_of_slot(bank.clone());
goto_end_of_slot(bank);
let bank = bank_client
.advance_slot(1, bank_forks.as_ref(), &mint_keypair.pubkey())
.unwrap();
Expand Down Expand Up @@ -6296,7 +6292,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
}

// Advance the bank so that the program becomes effective
goto_end_of_slot(bank.clone());
goto_end_of_slot(bank);
let bank = bank_client
.advance_slot(1, bank_forks.as_ref(), &mint_keypair.pubkey())
.unwrap();
Expand Down Expand Up @@ -11774,7 +11770,7 @@ fn test_deploy_last_epoch_slot() {
Some(&payer_keypair.pubkey()),
);
let signers = &[&payer_keypair, &upgrade_authority_keypair];
let transaction = Transaction::new(signers, message.clone(), bank.last_blockhash());
let transaction = Transaction::new(signers, message, bank.last_blockhash());
let ret = bank.process_transaction(&transaction);
assert!(ret.is_ok(), "ret: {ret:?}");
goto_end_of_slot(bank.clone());
Expand Down Expand Up @@ -11878,8 +11874,7 @@ fn test_loader_v3_to_v4_migration() {
Some(&payer_keypair.pubkey()),
);
let signers = &[&payer_keypair, &program_keypair];
let finalized_migration_transaction =
Transaction::new(signers, message.clone(), bank.last_blockhash());
let finalized_migration_transaction = Transaction::new(signers, message, bank.last_blockhash());

let mut upgradeable_programdata_account = AccountSharedData::new(
0,
Expand Down Expand Up @@ -11913,7 +11908,7 @@ fn test_loader_v3_to_v4_migration() {
);
let signers = &[&payer_keypair, &upgrade_authority_keypair];
let upgradeable_migration_transaction =
Transaction::new(signers, message.clone(), bank.last_blockhash());
Transaction::new(signers, message, bank.last_blockhash());

let payer_account = AccountSharedData::new(LAMPORTS_PER_SOL, 0, &system_program::id());
bank.store_account(
Expand All @@ -11937,19 +11932,15 @@ fn test_loader_v3_to_v4_migration() {
Some(&payer_keypair.pubkey()),
);
let signers = &[&payer_keypair];
let transaction = Transaction::new(signers, message.clone(), bank.last_blockhash());
let transaction = Transaction::new(signers, message, bank.last_blockhash());
let error = bank.process_transaction(&transaction).unwrap_err();
assert_eq!(
error,
TransactionError::InstructionError(0, InstructionError::InvalidArgument)
);

let bank = Bank::new_from_parent_with_bank_forks(
&bank_forks,
bank.clone(),
&Pubkey::default(),
next_slot,
);
let bank =
Bank::new_from_parent_with_bank_forks(&bank_forks, bank, &Pubkey::default(), next_slot);
next_slot += 1;

// All other error cases
Expand Down
6 changes: 3 additions & 3 deletions runtime/src/prioritization_fee_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ mod tests {
&Pubkey::new_unique(),
&Pubkey::new_unique(),
)];
sync_update(&prioritization_fee_cache, bank2.clone(), txs.iter());
sync_update(&prioritization_fee_cache, bank2, txs.iter());

let bank3 = Arc::new(Bank::new_from_parent(bank.clone(), &collector, 3));
let bank3 = Arc::new(Bank::new_from_parent(bank, &collector, 3));
sync_update(
&prioritization_fee_cache,
bank3.clone(),
Expand Down Expand Up @@ -919,7 +919,7 @@ mod tests {
&Pubkey::new_unique(),
),
];
sync_update(&prioritization_fee_cache, bank2.clone(), txs.iter());
sync_update(&prioritization_fee_cache, bank2, txs.iter());
}

// Assert after finalize with bank1 of slot 1,
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ pub(crate) fn remap_append_vec_file(
#[cfg(all(target_os = "linux", target_env = "gnu"))]
let append_vec_path_cstr = cstring_from_path(&append_vec_file_info.path)?;

let mut remapped_append_vec_path = append_vec_file_info.path.to_path_buf();
let mut remapped_append_vec_path = append_vec_file_info.path.clone();

// Break out of the loop in the following situations:
// 1. The new ID is the same as the original ID. This means we do not need to
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/stakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl Stakes<StakeAccount> {
stake_delegations,
unused: stakes.unused,
epoch: stakes.epoch,
stake_history: stakes.stake_history.clone(),
stake_history: stakes.stake_history,
})
}

Expand Down
4 changes: 2 additions & 2 deletions svm/src/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@ mod tests {
let mut error_metrics = TransactionErrorMetrics::default();
let load_result = load_transaction(
&mut account_loader,
&sanitized_tx.clone(),
&sanitized_tx,
Ok(ValidatedTransactionDetails::default()),
&mut error_metrics,
&Rent::default(),
Expand Down Expand Up @@ -2048,7 +2048,7 @@ mod tests {
let load_result = load_transaction(
&mut account_loader,
&sanitized_transaction,
validation_result.clone(),
validation_result,
&mut TransactionErrorMetrics::default(),
&rent,
);
Expand Down
2 changes: 1 addition & 1 deletion svm/src/rollback_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod tests {
let rollback_accounts = RollbackAccounts::new(
Some(nonce),
fee_payer_address,
rent_epoch_updated_fee_payer_account.clone(),
rent_epoch_updated_fee_payer_account,
u64::MAX, // ignored
);

Expand Down
8 changes: 4 additions & 4 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2126,7 +2126,7 @@ mod tests {
let fee_payer_address = message.fee_payer();
let fee_payer_account = AccountSharedData::new(1, 0, &Pubkey::default());
let mut mock_accounts = HashMap::new();
mock_accounts.insert(*fee_payer_address, fee_payer_account.clone());
mock_accounts.insert(*fee_payer_address, fee_payer_account);
let mock_bank = MockBankCallback {
account_shared_data: Arc::new(RwLock::new(mock_accounts)),
..Default::default()
Expand Down Expand Up @@ -2170,7 +2170,7 @@ mod tests {
let starting_balance = min_balance + transaction_fee - 1;
let fee_payer_account = AccountSharedData::new(starting_balance, 0, &Pubkey::default());
let mut mock_accounts = HashMap::new();
mock_accounts.insert(*fee_payer_address, fee_payer_account.clone());
mock_accounts.insert(*fee_payer_address, fee_payer_account);
let mock_bank = MockBankCallback {
account_shared_data: Arc::new(RwLock::new(mock_accounts)),
..Default::default()
Expand Down Expand Up @@ -2212,7 +2212,7 @@ mod tests {
let fee_payer_address = message.fee_payer();
let fee_payer_account = AccountSharedData::new(1_000_000, 0, &Pubkey::new_unique());
let mut mock_accounts = HashMap::new();
mock_accounts.insert(*fee_payer_address, fee_payer_account.clone());
mock_accounts.insert(*fee_payer_address, fee_payer_account);
let mock_bank = MockBankCallback {
account_shared_data: Arc::new(RwLock::new(mock_accounts)),
..Default::default()
Expand Down Expand Up @@ -2464,7 +2464,7 @@ mod tests {
.unwrap();

let mut mock_accounts = HashMap::new();
mock_accounts.insert(*fee_payer_address, fee_payer_account.clone());
mock_accounts.insert(*fee_payer_address, fee_payer_account);
let mock_bank = MockBankCallback {
account_shared_data: Arc::new(RwLock::new(mock_accounts)),
..Default::default()
Expand Down
45 changes: 17 additions & 28 deletions svm/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,17 +1528,15 @@ fn simd83_nonce_reuse(fee_paying_nonce: bool) -> Vec<SvmTestEntry> {
nonce::state::Data::new(fee_payer, initial_durable, LAMPORTS_PER_SIGNATURE);
let mut initial_nonce_account = AccountSharedData::new_data(
LAMPORTS_PER_SOL,
&nonce::versions::Versions::new(nonce::state::State::Initialized(
initial_nonce_data.clone(),
)),
&nonce::versions::Versions::new(nonce::state::State::Initialized(initial_nonce_data)),
&system_program::id(),
)
.unwrap();
initial_nonce_account.set_rent_epoch(u64::MAX);
let initial_nonce_info = NonceInfo::new(nonce_pubkey, initial_nonce_account.clone());

let advanced_durable = DurableNonce::from_blockhash(&LAST_BLOCKHASH);
let mut advanced_nonce_info = initial_nonce_info.clone();
let mut advanced_nonce_info = initial_nonce_info;
advanced_nonce_info
.try_advance_nonce(advanced_durable, LAMPORTS_PER_SIGNATURE)
.unwrap();
Expand Down Expand Up @@ -1695,10 +1693,7 @@ fn simd83_nonce_reuse(fee_paying_nonce: bool) -> Vec<SvmTestEntry> {
let mut test_entry = common_test_entry.clone();

let first_transaction = Transaction::new_signed_with_payer(
&[
successful_noop_instruction.clone(),
advance_instruction.clone(),
],
&[successful_noop_instruction.clone(), advance_instruction],
Some(&fee_payer),
&[&fee_payer_keypair],
Hash::default(),
Expand Down Expand Up @@ -1921,7 +1916,7 @@ fn simd83_nonce_reuse(fee_paying_nonce: bool) -> Vec<SvmTestEntry> {

test_entry.push_transaction(first_transaction);
test_entry.push_nonce_transaction_with_status(
second_transaction.clone(),
second_transaction,
nonce_pubkey,
ExecutionStatus::Discarded,
);
Expand All @@ -1944,7 +1939,7 @@ fn simd83_nonce_reuse(fee_paying_nonce: bool) -> Vec<SvmTestEntry> {
// * a successful blockhash transaction that changes the nonce authority
// * a nonce transaction that uses the nonce with the new authority; this transaction succeeds
if !fee_paying_nonce {
let mut test_entry = common_test_entry.clone();
let mut test_entry = common_test_entry;

let new_authority_keypair = Keypair::new();
let new_authority = new_authority_keypair.pubkey();
Expand All @@ -1963,15 +1958,15 @@ fn simd83_nonce_reuse(fee_paying_nonce: bool) -> Vec<SvmTestEntry> {
let second_transaction = Transaction::new_signed_with_payer(
&[
system_instruction::advance_nonce_account(&nonce_pubkey, &new_authority),
successful_noop_instruction.clone(),
successful_noop_instruction,
],
Some(&fee_payer),
&[&fee_payer_keypair, &new_authority_keypair],
*initial_durable.as_hash(),
);

test_entry.push_transaction(first_transaction);
test_entry.push_nonce_transaction(second_transaction.clone(), nonce_pubkey);
test_entry.push_nonce_transaction(second_transaction, nonce_pubkey);

test_entry.decrease_expected_lamports(&fee_payer, LAMPORTS_PER_SIGNATURE * 2);

Expand Down Expand Up @@ -2227,17 +2222,15 @@ fn simd83_fee_payer_deallocate() -> Vec<SvmTestEntry> {
nonce::state::Data::new(dealloc_fee_payer, initial_durable, LAMPORTS_PER_SIGNATURE);
let mut initial_nonce_account = AccountSharedData::new_data(
LAMPORTS_PER_SOL,
&nonce::versions::Versions::new(nonce::state::State::Initialized(
initial_nonce_data.clone(),
)),
&nonce::versions::Versions::new(nonce::state::State::Initialized(initial_nonce_data)),
&system_program::id(),
)
.unwrap();
initial_nonce_account.set_rent_epoch(u64::MAX);
let initial_nonce_info = NonceInfo::new(nonce_pubkey, initial_nonce_account.clone());

let advanced_durable = DurableNonce::from_blockhash(&LAST_BLOCKHASH);
let mut advanced_nonce_info = initial_nonce_info.clone();
let mut advanced_nonce_info = initial_nonce_info;
advanced_nonce_info
.try_advance_nonce(advanced_durable, LAMPORTS_PER_SIGNATURE)
.unwrap();
Expand Down Expand Up @@ -2363,18 +2356,16 @@ fn simd83_account_reallocate() -> Vec<SvmTestEntry> {
// * successful large realloc up
// * transaction is aborted based on the new transaction data size post-realloc
{
let mut test_entry = common_test_entry.clone();
let mut test_entry = common_test_entry;

let new_target_size = target_start_size + MAX_PERMITTED_DATA_INCREASE;

let realloc_transaction = WriteProgramInstruction::Realloc(new_target_size)
.create_transaction(program_id, &fee_payer_keypair, target, None);
test_entry.push_transaction(realloc_transaction);

test_entry.push_transaction_with_status(
print_transaction.clone(),
ExecutionStatus::ProcessedFailed,
);
test_entry
.push_transaction_with_status(print_transaction, ExecutionStatus::ProcessedFailed);

test_entry.update_expected_account_data(target, &mk_target(new_target_size));

Expand Down Expand Up @@ -2979,7 +2970,7 @@ fn program_cache_stats() {

test_entry.push_transaction_with_status(
make_transaction(&[
failing_transfer_instruction.clone(),
failing_transfer_instruction,
succesful_noop_instruction.clone(),
succesful_transfer_instruction.clone(),
]),
Expand All @@ -2992,7 +2983,7 @@ fn program_cache_stats() {
test_entry.push_transaction_with_status(
make_transaction(&[
succesful_noop_instruction.clone(),
fee_only_noop_instruction.clone(),
fee_only_noop_instruction,
]),
ExecutionStatus::ProcessedFailed,
);
Expand Down Expand Up @@ -3192,9 +3183,7 @@ fn svm_inspect_nonce_load_failure(fee_paying_nonce: bool) {
nonce::state::Data::new(fee_payer, initial_durable, LAMPORTS_PER_SIGNATURE);
let mut initial_nonce_account = AccountSharedData::new_data(
LAMPORTS_PER_SOL,
&nonce::versions::Versions::new(nonce::state::State::Initialized(
initial_nonce_data.clone(),
)),
&nonce::versions::Versions::new(nonce::state::State::Initialized(initial_nonce_data)),
&system_program::id(),
)
.unwrap();
Expand All @@ -3203,7 +3192,7 @@ fn svm_inspect_nonce_load_failure(fee_paying_nonce: bool) {
let initial_nonce_info = NonceInfo::new(nonce_pubkey, initial_nonce_account.clone());

let advanced_durable = DurableNonce::from_blockhash(&LAST_BLOCKHASH);
let mut advanced_nonce_info = initial_nonce_info.clone();
let mut advanced_nonce_info = initial_nonce_info;
advanced_nonce_info
.try_advance_nonce(advanced_durable, LAMPORTS_PER_SIGNATURE)
.unwrap();
Expand Down Expand Up @@ -3376,7 +3365,7 @@ fn svm_inspect_account() {

let mut final_test_entry = SvmTestEntry {
initial_accounts: initial_test_entry.final_accounts.clone(),
final_accounts: initial_test_entry.final_accounts.clone(),
final_accounts: initial_test_entry.final_accounts,
..SvmTestEntry::default()
};

Expand Down
Loading
Loading