Don't use move semantics if not needed (#8793)

This commit is contained in:
Jack May
2020-03-11 14:37:23 -07:00
committed by GitHub
parent 5f5824d78d
commit 6eb4973780
32 changed files with 133 additions and 137 deletions

View File

@ -256,7 +256,7 @@ mod tests {
budget_instruction::payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 1);
instructions[1].accounts = vec![]; // <!-- Attack! Prevent accounts from being passed into processor.
let message = Message::new(instructions);
let message = Message::new(&instructions);
assert_eq!(
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
@ -276,7 +276,7 @@ mod tests {
let budget_pubkey = budget_keypair.pubkey();
let instructions =
budget_instruction::payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 100);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
.unwrap();
@ -302,7 +302,7 @@ mod tests {
None,
1,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
.unwrap();
@ -315,7 +315,7 @@ mod tests {
.unwrap();
let instruction =
budget_instruction::apply_signature(&mallory_pubkey, &budget_pubkey, &bob_pubkey);
let mut message = Message::new(vec![instruction]);
let mut message = Message::new(&[instruction]);
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
message.account_keys.insert(3, alice_pubkey);
@ -352,7 +352,7 @@ mod tests {
None,
1,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
.unwrap();
@ -365,7 +365,7 @@ mod tests {
.unwrap();
let instruction =
budget_instruction::apply_timestamp(&mallory_pubkey, &budget_pubkey, &bob_pubkey, dt);
let mut message = Message::new(vec![instruction]);
let mut message = Message::new(&[instruction]);
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
message.account_keys.insert(3, alice_pubkey);
@ -402,7 +402,7 @@ mod tests {
None,
1,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
.unwrap();
@ -472,7 +472,7 @@ mod tests {
Some(alice_pubkey),
1,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
.unwrap();
@ -550,7 +550,7 @@ mod tests {
game_hash,
41,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client
.send_message(&[&alice_keypair, &budget_keypair], message)
.unwrap();
@ -570,7 +570,7 @@ mod tests {
// Anyone can sign the message, but presumably it's Bob, since he's the
// one claiming the payout.
let message = Message::new_with_payer(vec![instruction], Some(&bob_pubkey));
let message = Message::new_with_payer(&[instruction], Some(&bob_pubkey));
bank_client.send_message(&[&bob_keypair], message).unwrap();
assert_eq!(bank_client.get_balance(&alice_pubkey).unwrap(), 0);

View File

@ -603,7 +603,7 @@ mod test {
);
client
.send_message(&[owner, &new], Message::new(vec![instruction]))
.send_message(&[owner, &new], Message::new(&[instruction]))
.expect(&format!("{}:{}", line!(), file!()));
new.pubkey()
}

View File

@ -32,11 +32,11 @@ pub fn create_genesis<T: Client>(from: &Keypair, client: &T, amount: u64) -> Key
);
client
.send_message(&[&from, &genesis], Message::new(vec![instruction]))
.send_message(&[&from, &genesis], Message::new(&[instruction]))
.unwrap();
let instruction = librapay_instruction::genesis(&genesis.pubkey(), amount);
let message = Message::new_with_payer(vec![instruction], Some(&from.pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&from.pubkey()));
client.send_message(&[from, &genesis], message).unwrap();
genesis

View File

@ -93,7 +93,7 @@ mod tests {
owner_pubkey,
lamports,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client.send_message(&[payer_keypair, account_keypair], message)
}
@ -109,7 +109,7 @@ mod tests {
&old_owner_keypair.pubkey(),
new_owner_pubkey,
);
let message = Message::new_with_payer(vec![instruction], Some(&payer_keypair.pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&payer_keypair.pubkey()));
bank_client.send_message(&[payer_keypair, old_owner_keypair], message)
}

View File

@ -187,7 +187,7 @@ mod tests {
date_instruction::create_account(&payer_keypair.pubkey(), &date_pubkey, 1);
instructions.push(date_instruction::store(&date_pubkey, date));
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client.send_message(&[payer_keypair, date_keypair], message)
}
@ -199,7 +199,7 @@ mod tests {
) -> Result<Signature> {
let date_pubkey = date_keypair.pubkey();
let instruction = date_instruction::store(&date_pubkey, date);
let message = Message::new_with_payer(vec![instruction], Some(&payer_keypair.pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&payer_keypair.pubkey()));
bank_client.send_message(&[payer_keypair, date_keypair], message)
}
@ -222,7 +222,7 @@ mod tests {
&date_pubkey,
lamports,
);
let message = Message::new(instructions);
let message = Message::new(&instructions);
bank_client.send_message(&[payer_keypair, contract_keypair], message)
}
@ -257,7 +257,7 @@ mod tests {
) -> Result<Signature> {
let instruction =
vest_instruction::redeem_tokens(&contract_pubkey, &date_pubkey, &payee_pubkey);
let message = Message::new_with_payer(vec![instruction], Some(&payer_keypair.pubkey()));
let message = Message::new_with_payer(&[instruction], Some(&payer_keypair.pubkey()));
bank_client.send_message(&[payer_keypair], message)
}
@ -353,7 +353,7 @@ mod tests {
);
instructions[1].accounts = vec![]; // <!-- Attack! Prevent accounts from being passed into processor.
let message = Message::new(instructions);
let message = Message::new(&instructions);
assert_eq!(
bank_client
.send_message(&[&alice_keypair, &contract_keypair], message)