Rename 'new_account' to 'new_user_account'

And 'new_program_account' to 'new_account'
This commit is contained in:
Greg Fitzgerald
2019-04-02 17:01:56 -06:00
parent 7b82e96467
commit 43bb813cbe
32 changed files with 107 additions and 86 deletions

View File

@ -593,22 +593,27 @@ mod tests {
// fund another account so we can send 2 good transactions in a single batch.
let keypair = Keypair::new();
let fund_tx =
SystemTransaction::new_account(&mint_keypair, &keypair.pubkey(), 2, start_hash, 0);
let fund_tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair.pubkey(),
2,
start_hash,
0,
);
bank.process_transaction(&fund_tx).unwrap();
// good tx
let to = Pubkey::new_rand();
let tx = SystemTransaction::new_account(&mint_keypair, &to, 1, start_hash, 0);
let tx = SystemTransaction::new_user_account(&mint_keypair, &to, 1, start_hash, 0);
// good tx, but no verify
let to2 = Pubkey::new_rand();
let tx_no_ver = SystemTransaction::new_account(&keypair, &to2, 2, start_hash, 0);
let tx_no_ver = SystemTransaction::new_user_account(&keypair, &to2, 2, start_hash, 0);
// bad tx, AccountNotFound
let keypair = Keypair::new();
let to3 = Pubkey::new_rand();
let tx_anf = SystemTransaction::new_account(&keypair, &to3, 1, start_hash, 0);
let tx_anf = SystemTransaction::new_user_account(&keypair, &to3, 1, start_hash, 0);
// send 'em over
let packets = to_packets(&[tx_no_ver, tx_anf, tx]);
@ -671,7 +676,7 @@ mod tests {
// Process a batch that includes a transaction that receives two lamports.
let alice = Keypair::new();
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&alice.pubkey(),
2,
@ -685,7 +690,7 @@ mod tests {
.unwrap();
// Process a second batch that spends one of those lamports.
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&alice,
&mint_keypair.pubkey(),
1,

View File

@ -141,7 +141,8 @@ mod test {
let keypair = Keypair::new();
let mut blockhash = entries[3].hash;
let tx = SystemTransaction::new_account(&keypair, &keypair.pubkey(), 1, Hash::default(), 0);
let tx =
SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 1, Hash::default(), 0);
let entry = Entry::new(&mut blockhash, 1, vec![tx]);
blockhash = entry.hash;
entries.push(entry);

View File

@ -421,7 +421,7 @@ mod tests {
let bank = Bank::new(&genesis_block);
let keypair = Keypair::new();
let slot_entries = create_ticks(genesis_block.ticks_per_slot - 1, genesis_block.hash());
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair.pubkey(),
1,
@ -453,8 +453,13 @@ mod tests {
for _ in 0..3 {
// Transfer one token from the mint to a random account
let keypair = Keypair::new();
let tx =
SystemTransaction::new_account(&mint_keypair, &keypair.pubkey(), 1, blockhash, 0);
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair.pubkey(),
1,
blockhash,
0,
);
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
last_entry_hash = entry.hash;
entries.push(entry);
@ -462,7 +467,8 @@ mod tests {
// Add a second Transaction that will produce a
// InstructionError<0, ResultWithNegativeLamports> error when processed
let keypair2 = Keypair::new();
let tx = SystemTransaction::new_account(&keypair, &keypair2.pubkey(), 42, blockhash, 0);
let tx =
SystemTransaction::new_user_account(&keypair, &keypair2.pubkey(), 42, blockhash, 0);
let entry = Entry::new(&last_entry_hash, 1, vec![tx]);
last_entry_hash = entry.hash;
entries.push(entry);
@ -539,7 +545,7 @@ mod tests {
let blockhash = bank.last_blockhash();
// ensure bank can process 2 entries that have a common account and no tick is registered
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair1.pubkey(),
2,
@ -547,7 +553,7 @@ mod tests {
0,
);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair2.pubkey(),
2,
@ -577,7 +583,7 @@ mod tests {
let entry_1_to_mint = next_entry(
&bank.last_blockhash(),
1,
vec![SystemTransaction::new_account(
vec![SystemTransaction::new_user_account(
&keypair1,
&mint_keypair.pubkey(),
1,
@ -590,14 +596,14 @@ mod tests {
&entry_1_to_mint.hash,
1,
vec![
SystemTransaction::new_account(
SystemTransaction::new_user_account(
&keypair2,
&keypair3.pubkey(),
2,
bank.last_blockhash(),
0,
), // should be fine
SystemTransaction::new_account(
SystemTransaction::new_user_account(
&keypair1,
&mint_keypair.pubkey(),
2,
@ -636,7 +642,7 @@ mod tests {
&bank.last_blockhash(),
1,
vec![
SystemTransaction::new_account(
SystemTransaction::new_user_account(
&keypair1,
&mint_keypair.pubkey(),
1,
@ -657,14 +663,14 @@ mod tests {
&entry_1_to_mint.hash,
1,
vec![
SystemTransaction::new_account(
SystemTransaction::new_user_account(
&keypair2,
&keypair3.pubkey(),
2,
bank.last_blockhash(),
0,
), // should be fine
SystemTransaction::new_account(
SystemTransaction::new_user_account(
&keypair1,
&mint_keypair.pubkey(),
2,
@ -709,7 +715,7 @@ mod tests {
let keypair4 = Keypair::new();
//load accounts
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair1.pubkey(),
1,
@ -717,7 +723,7 @@ mod tests {
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair2.pubkey(),
1,
@ -728,7 +734,7 @@ mod tests {
// ensure bank can process 2 entries that do not have a common account and no tick is registered
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&keypair1,
&keypair3.pubkey(),
1,
@ -736,7 +742,7 @@ mod tests {
0,
);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&keypair2,
&keypair4.pubkey(),
1,
@ -760,7 +766,7 @@ mod tests {
let keypair4 = Keypair::new();
//load accounts
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair1.pubkey(),
1,
@ -768,7 +774,7 @@ mod tests {
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&mint_keypair,
&keypair2.pubkey(),
1,
@ -783,10 +789,11 @@ mod tests {
}
// ensure bank can process 2 entries that do not have a common account and tick is registered
let tx = SystemTransaction::new_account(&keypair2, &keypair3.pubkey(), 1, blockhash, 0);
let tx =
SystemTransaction::new_user_account(&keypair2, &keypair3.pubkey(), 1, blockhash, 0);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tick = next_entry(&entry_1.hash, 1, vec![]);
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&keypair1,
&keypair4.pubkey(),
1,
@ -802,7 +809,7 @@ mod tests {
assert_eq!(bank.get_balance(&keypair4.pubkey()), 1);
// ensure that an error is returned for an empty account (keypair2)
let tx = SystemTransaction::new_account(
let tx = SystemTransaction::new_user_account(
&keypair2,
&keypair3.pubkey(),
1,

View File

@ -124,7 +124,7 @@ mod tests {
Entry::new_mut(
&mut id,
&mut num_hashes,
vec![SystemTransaction::new_account(
vec![SystemTransaction::new_user_account(
&keypair,
&keypair.pubkey(),
1,

View File

@ -494,8 +494,8 @@ mod tests {
// First, verify entries
let keypair = Keypair::new();
let tx0 = SystemTransaction::new_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx1 = SystemTransaction::new_account(&keypair, &keypair.pubkey(), 1, zero, 0);
let tx0 = SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx1 = SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 1, zero, 0);
let mut e0 = Entry::new(&zero, 0, vec![tx0.clone(), tx1.clone()]);
assert!(e0.verify(&zero));
@ -545,7 +545,7 @@ mod tests {
fn test_next_entry_panic() {
let zero = Hash::default();
let keypair = Keypair::new();
let tx = SystemTransaction::new_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx = SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
next_entry(&zero, 0, vec![tx]);
}
@ -553,7 +553,7 @@ mod tests {
fn test_serialized_size() {
let zero = Hash::default();
let keypair = Keypair::new();
let tx = SystemTransaction::new_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx = SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let entry = next_entry(&zero, 1, vec![tx.clone()]);
assert_eq!(
Entry::serialized_size(&[tx]),

View File

@ -318,7 +318,7 @@ pub fn make_active_set_entries(
num_ending_ticks: u64,
) -> (Vec<Entry>, Keypair) {
// 1) Assume the active_keypair node has no lamports staked
let transfer_tx = SystemTransaction::new_account(
let transfer_tx = SystemTransaction::new_user_account(
&lamport_source,
&active_keypair.pubkey(),
stake,

View File

@ -296,8 +296,13 @@ impl LocalCluster {
) -> u64 {
trace!("getting leader blockhash");
let blockhash = client.get_recent_blockhash().unwrap();
let mut tx =
SystemTransaction::new_account(&source_keypair, dest_pubkey, lamports, blockhash, 0);
let mut tx = SystemTransaction::new_user_account(
&source_keypair,
dest_pubkey,
lamports,
blockhash,
0,
);
info!(
"executing transfer of {} from {} to {}",
lamports,

View File

@ -612,7 +612,7 @@ mod tests {
fn test_to_packets() {
let keypair = Keypair::new();
let hash = Hash::new(&[1; 32]);
let tx = SystemTransaction::new_account(&keypair, &keypair.pubkey(), 1, hash, 0);
let tx = SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 1, hash, 0);
let rv = to_packets(&vec![tx.clone(); 1]);
assert_eq!(rv.len(), 1);
assert_eq!(rv[0].read().unwrap().packets.len(), 1);

View File

@ -434,7 +434,7 @@ impl Replicator {
{
let blockhash = client.get_recent_blockhash().expect("blockhash");
//TODO the account space needs to be well defined somewhere
let tx = SystemTransaction::new_program_account(
let tx = SystemTransaction::new_account(
keypair,
&storage_keypair.pubkey(),
blockhash,

View File

@ -354,7 +354,8 @@ mod tests {
let (subscriber, _id_receiver, mut receiver) = Subscriber::new_test("accountNotification");
rpc.account_subscribe(session, subscriber, contract_state.pubkey().to_string());
let tx = SystemTransaction::new_account(&alice, &contract_funds.pubkey(), 51, blockhash, 0);
let tx =
SystemTransaction::new_user_account(&alice, &contract_funds.pubkey(), 51, blockhash, 0);
let arc_bank = process_transaction_and_notify(&arc_bank, &tx, &rpc.subscriptions).unwrap();
let ixs = BudgetInstruction::new_when_signed(
@ -390,7 +391,7 @@ mod tests {
assert_eq!(serde_json::to_string(&expected).unwrap(), response);
}
let tx = SystemTransaction::new_account(&alice, &witness.pubkey(), 1, blockhash, 0);
let tx = SystemTransaction::new_user_account(&alice, &witness.pubkey(), 1, blockhash, 0);
let arc_bank = process_transaction_and_notify(&arc_bank, &tx, &rpc.subscriptions).unwrap();
sleep(Duration::from_millis(200));
let ix = BudgetInstruction::new_apply_signature(

View File

@ -211,7 +211,7 @@ mod tests {
let bank = Bank::new(&genesis_block);
let alice = Keypair::new();
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_program_account(
let tx = SystemTransaction::new_account(
&mint_keypair,
&alice.pubkey(),
blockhash,
@ -257,7 +257,7 @@ mod tests {
let bank = Bank::new(&genesis_block);
let alice = Keypair::new();
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_program_account(
let tx = SystemTransaction::new_account(
&mint_keypair,
&alice.pubkey(),
blockhash,

View File

@ -279,7 +279,7 @@ impl StorageStage {
if let Some(account) = account_to_create {
if client.get_account_data(&account).is_err() {
// TODO the account space needs to be well defined somewhere
let tx = SystemTransaction::new_program_account(
let tx = SystemTransaction::new_account(
keypair,
&storage_keypair.pubkey(),
blockhash,

View File

@ -10,7 +10,7 @@ pub fn test_tx() -> Transaction {
let keypair1 = Keypair::new();
let pubkey1 = keypair1.pubkey();
let zero = Hash::default();
SystemTransaction::new_account(&keypair1, &pubkey1, 42, zero, 0)
SystemTransaction::new_user_account(&keypair1, &pubkey1, 42, zero, 0)
}
pub fn test_multisig_tx() -> Transaction {

View File

@ -140,7 +140,7 @@ fn test_replay() {
let entry0 = next_entry_mut(&mut cur_hash, i, vec![]);
let entry_tick0 = next_entry_mut(&mut cur_hash, i + 1, vec![]);
let tx0 = SystemTransaction::new_account(
let tx0 = SystemTransaction::new_user_account(
&mint_keypair,
&bob_keypair.pubkey(),
transfer_amount,