Cleanup stragglers from move-to-transfer rename (#3947)
This commit is contained in:
@ -1593,14 +1593,14 @@ mod tests {
|
||||
let key2 = Keypair::new();
|
||||
let parent = Arc::new(Bank::new(&genesis_block));
|
||||
|
||||
let tx_move_mint_to_1 =
|
||||
let tx_transfer_mint_to_1 =
|
||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
||||
trace!("parent process tx ");
|
||||
assert_eq!(parent.process_transaction(&tx_move_mint_to_1), Ok(()));
|
||||
assert_eq!(parent.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
||||
trace!("done parent process tx ");
|
||||
assert_eq!(parent.transaction_count(), 1);
|
||||
assert_eq!(
|
||||
parent.get_signature_status(&tx_move_mint_to_1.signatures[0]),
|
||||
parent.get_signature_status(&tx_transfer_mint_to_1.signatures[0]),
|
||||
Some(Ok(()))
|
||||
);
|
||||
|
||||
@ -1608,18 +1608,18 @@ mod tests {
|
||||
let bank = new_from_parent(&parent);
|
||||
trace!("done new form parent");
|
||||
assert_eq!(
|
||||
bank.get_signature_status(&tx_move_mint_to_1.signatures[0]),
|
||||
bank.get_signature_status(&tx_transfer_mint_to_1.signatures[0]),
|
||||
Some(Ok(()))
|
||||
);
|
||||
|
||||
assert_eq!(bank.transaction_count(), parent.transaction_count());
|
||||
let tx_move_1_to_2 =
|
||||
let tx_transfer_1_to_2 =
|
||||
system_transaction::transfer(&key1, &key2.pubkey(), 1, genesis_block.hash(), 0);
|
||||
assert_eq!(bank.process_transaction(&tx_move_1_to_2), Ok(()));
|
||||
assert_eq!(bank.process_transaction(&tx_transfer_1_to_2), Ok(()));
|
||||
assert_eq!(bank.transaction_count(), 2);
|
||||
assert_eq!(parent.transaction_count(), 1);
|
||||
assert_eq!(
|
||||
parent.get_signature_status(&tx_move_1_to_2.signatures[0]),
|
||||
parent.get_signature_status(&tx_transfer_1_to_2.signatures[0]),
|
||||
None
|
||||
);
|
||||
|
||||
@ -1630,11 +1630,11 @@ mod tests {
|
||||
assert_eq!(bank.get_balance(&key2.pubkey()), 1);
|
||||
trace!("start");
|
||||
assert_eq!(
|
||||
bank.get_signature_status(&tx_move_mint_to_1.signatures[0]),
|
||||
bank.get_signature_status(&tx_transfer_mint_to_1.signatures[0]),
|
||||
Some(Ok(()))
|
||||
);
|
||||
assert_eq!(
|
||||
bank.get_signature_status(&tx_move_1_to_2.signatures[0]),
|
||||
bank.get_signature_status(&tx_transfer_1_to_2.signatures[0]),
|
||||
Some(Ok(()))
|
||||
);
|
||||
|
||||
@ -1731,13 +1731,13 @@ mod tests {
|
||||
bank.fee_calculator.lamports_per_signature = 2;
|
||||
let key = Keypair::new();
|
||||
|
||||
let mut move_instruction =
|
||||
let mut transfer_instruction =
|
||||
system_instruction::transfer(&mint_keypair.pubkey(), &key.pubkey(), 0);
|
||||
move_instruction.accounts[0].is_signer = false;
|
||||
transfer_instruction.accounts[0].is_signer = false;
|
||||
|
||||
let tx = Transaction::new_signed_instructions(
|
||||
&Vec::<&Keypair>::new(),
|
||||
vec![move_instruction],
|
||||
vec![transfer_instruction],
|
||||
bank.last_blockhash(),
|
||||
);
|
||||
|
||||
@ -1813,9 +1813,9 @@ mod tests {
|
||||
let (genesis_block, mint_keypair) = GenesisBlock::new(500);
|
||||
let bank = Arc::new(Bank::new(&genesis_block));
|
||||
let key1 = Keypair::new();
|
||||
let tx_move_mint_to_1 =
|
||||
let tx_transfer_mint_to_1 =
|
||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
||||
assert_eq!(bank.process_transaction(&tx_move_mint_to_1), Ok(()));
|
||||
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
||||
assert_eq!(bank.is_delta.load(Ordering::Relaxed), true);
|
||||
}
|
||||
|
||||
@ -1827,9 +1827,9 @@ mod tests {
|
||||
assert_eq!(bank.is_votable(), false);
|
||||
|
||||
// Set is_delta to true
|
||||
let tx_move_mint_to_1 =
|
||||
let tx_transfer_mint_to_1 =
|
||||
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_block.hash(), 0);
|
||||
assert_eq!(bank.process_transaction(&tx_move_mint_to_1), Ok(()));
|
||||
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
|
||||
assert_eq!(bank.is_votable(), false);
|
||||
|
||||
// Register enough ticks to hit max tick height
|
||||
|
@ -160,12 +160,12 @@ mod tests {
|
||||
|
||||
// Create 2-2 Multisig Transfer instruction.
|
||||
let bob_pubkey = Pubkey::new_rand();
|
||||
let mut move_instruction = system_instruction::transfer(&john_pubkey, &bob_pubkey, 42);
|
||||
move_instruction
|
||||
let mut transfer_instruction = system_instruction::transfer(&john_pubkey, &bob_pubkey, 42);
|
||||
transfer_instruction
|
||||
.accounts
|
||||
.push(AccountMeta::new(jane_pubkey, true));
|
||||
|
||||
let message = Message::new(vec![move_instruction]);
|
||||
let message = Message::new(vec![transfer_instruction]);
|
||||
bank_client.send_message(&doe_keypairs, message).unwrap();
|
||||
assert_eq!(bank_client.get_balance(&bob_pubkey).unwrap(), 42);
|
||||
}
|
||||
|
@ -50,7 +50,10 @@ fn assign_account_to_program(
|
||||
keyed_accounts[FROM_ACCOUNT_INDEX].account.owner = *program_id;
|
||||
Ok(())
|
||||
}
|
||||
fn move_lamports(keyed_accounts: &mut [KeyedAccount], lamports: u64) -> Result<(), SystemError> {
|
||||
fn transfer_lamports(
|
||||
keyed_accounts: &mut [KeyedAccount],
|
||||
lamports: u64,
|
||||
) -> Result<(), SystemError> {
|
||||
if lamports > keyed_accounts[FROM_ACCOUNT_INDEX].account.lamports {
|
||||
debug!(
|
||||
"Transfer: insufficient lamports ({}, need {})",
|
||||
@ -91,7 +94,7 @@ pub fn process_instruction(
|
||||
}
|
||||
assign_account_to_program(keyed_accounts, &program_id)
|
||||
}
|
||||
SystemInstruction::Transfer { lamports } => move_lamports(keyed_accounts, lamports),
|
||||
SystemInstruction::Transfer { lamports } => transfer_lamports(keyed_accounts, lamports),
|
||||
}
|
||||
.map_err(|e| InstructionError::CustomError(e as u32))
|
||||
} else {
|
||||
@ -249,7 +252,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_move_lamports() {
|
||||
fn test_transfer_lamports() {
|
||||
let from = Pubkey::new_rand();
|
||||
let mut from_account = Account::new(100, 0, &Pubkey::new(&[2; 32])); // account owner should not matter
|
||||
let to = Pubkey::new_rand();
|
||||
@ -258,7 +261,7 @@ mod tests {
|
||||
KeyedAccount::new(&from, true, &mut from_account),
|
||||
KeyedAccount::new(&to, false, &mut to_account),
|
||||
];
|
||||
move_lamports(&mut keyed_accounts, 50).unwrap();
|
||||
transfer_lamports(&mut keyed_accounts, 50).unwrap();
|
||||
let from_lamports = from_account.lamports;
|
||||
let to_lamports = to_account.lamports;
|
||||
assert_eq!(from_lamports, 50);
|
||||
@ -269,7 +272,7 @@ mod tests {
|
||||
KeyedAccount::new(&from, true, &mut from_account),
|
||||
KeyedAccount::new(&to, false, &mut to_account),
|
||||
];
|
||||
let result = move_lamports(&mut keyed_accounts, 100);
|
||||
let result = transfer_lamports(&mut keyed_accounts, 100);
|
||||
assert_eq!(result, Err(SystemError::ResultWithNegativeLamports));
|
||||
assert_eq!(from_account.lamports, 50);
|
||||
assert_eq!(to_account.lamports, 51);
|
||||
|
Reference in New Issue
Block a user