From e091aa87ea7eb43e58df1438043c1bed6827281e Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Fri, 15 Mar 2019 10:02:28 -0600 Subject: [PATCH] More precise constructor names --- core/src/sigverify.rs | 2 +- drone/src/drone.rs | 4 ++-- drone/tests/local-drone.rs | 2 +- programs/bpf/tests/programs.rs | 6 +++--- programs/budget/src/budget_program.rs | 2 +- programs/failure/tests/failure.rs | 2 +- programs/noop/tests/noop.rs | 2 +- programs/storage_api/src/lib.rs | 8 ++++---- runtime/src/accounts.rs | 20 ++++++++++---------- runtime/src/bank.rs | 2 +- sdk/src/loader_transaction.rs | 4 ++-- sdk/src/system_transaction.rs | 8 ++++---- sdk/src/transaction.rs | 16 ++++++++-------- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/core/src/sigverify.rs b/core/src/sigverify.rs index 047074cf33..2bbe338ec5 100644 --- a/core/src/sigverify.rs +++ b/core/src/sigverify.rs @@ -503,7 +503,7 @@ mod tests { let instructions = vec![CompiledInstruction::new(0, &system_instruction, vec![0, 1])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &keypairs, &[], blockhash, diff --git a/drone/src/drone.rs b/drone/src/drone.rs index 332ee77432..41105d0cf4 100644 --- a/drone/src/drone.rs +++ b/drone/src/drone.rs @@ -132,7 +132,7 @@ impl Drone { space: 0, program_id: system_program::id(), }; - let mut transaction = Transaction::new( + let mut transaction = Transaction::new_signed( &self.mint_keypair, &[to], &system_program::id(), @@ -408,7 +408,7 @@ mod tests { space: 0, program_id: system_program::id(), }; - let mut expected_tx = Transaction::new( + let mut expected_tx = Transaction::new_signed( &keypair, &[to], &system_program::id(), diff --git a/drone/tests/local-drone.rs b/drone/tests/local-drone.rs index 29588dc0db..636a10adbb 100644 --- a/drone/tests/local-drone.rs +++ b/drone/tests/local-drone.rs @@ -17,7 +17,7 @@ fn test_local_drone() { space: 0, program_id: system_program::id(), }; - let mut expected_tx = Transaction::new( + let mut expected_tx = Transaction::new_signed( &keypair, &[to], &system_program::id(), diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index 67f307ea4f..aa2330d6f3 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -43,7 +43,7 @@ mod bpf { // Call user program let program_id = load_program(&bank, &mint_keypair, &bpf_loader::id(), elf); - let tx = Transaction::new( + let tx = Transaction::new_signed( &mint_keypair, &[], &program_id, @@ -86,7 +86,7 @@ mod bpf { // Call user program let program_id = load_program(&bank, &mint_keypair, &loader_id, elf); - let tx = Transaction::new( + let tx = Transaction::new_signed( &mint_keypair, &[], &program_id, @@ -132,7 +132,7 @@ mod bpf { // Call user program let program_id = load_program(&bank, &mint_keypair, &loader_id, elf); - let tx = Transaction::new( + let tx = Transaction::new_signed( &mint_keypair, &[], &program_id, diff --git a/programs/budget/src/budget_program.rs b/programs/budget/src/budget_program.rs index 41fa4e81bd..00ec14b579 100644 --- a/programs/budget/src/budget_program.rs +++ b/programs/budget/src/budget_program.rs @@ -177,7 +177,7 @@ mod test { let from = Keypair::new(); let contract = Keypair::new(); let data = (1u8, 2u8, 3u8); - let tx = Transaction::new( + let tx = Transaction::new_signed( &from, &[contract.pubkey()], &id(), diff --git a/programs/failure/tests/failure.rs b/programs/failure/tests/failure.rs index 3343434bae..dfc34c83cf 100644 --- a/programs/failure/tests/failure.rs +++ b/programs/failure/tests/failure.rs @@ -14,7 +14,7 @@ fn test_program_native_failure() { let program_id = load_program(&bank, &mint_keypair, &native_loader::id(), program); // Call user program - let tx = Transaction::new( + let tx = Transaction::new_signed( &mint_keypair, &[], &program_id, diff --git a/programs/noop/tests/noop.rs b/programs/noop/tests/noop.rs index 764d4dd810..621c358f8a 100644 --- a/programs/noop/tests/noop.rs +++ b/programs/noop/tests/noop.rs @@ -15,7 +15,7 @@ fn test_program_native_noop() { let program_id = load_program(&bank, &mint_keypair, &native_loader::id(), program); // Call user program - let tx = Transaction::new( + let tx = Transaction::new_signed( &mint_keypair, &[], &program_id, diff --git a/programs/storage_api/src/lib.rs b/programs/storage_api/src/lib.rs index f1ec6572f9..d9a9c7f5db 100644 --- a/programs/storage_api/src/lib.rs +++ b/programs/storage_api/src/lib.rs @@ -90,7 +90,7 @@ impl StorageTransaction { entry_height, signature, }; - Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) + Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0) } pub fn new_advertise_recent_blockhash( @@ -103,7 +103,7 @@ impl StorageTransaction { hash: storage_hash, entry_height, }; - Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) + Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0) } pub fn new_proof_validation( @@ -116,7 +116,7 @@ impl StorageTransaction { entry_height, proof_mask, }; - Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) + Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0) } pub fn new_reward_claim( @@ -125,6 +125,6 @@ impl StorageTransaction { entry_height: u64, ) -> Transaction { let program = StorageProgram::ClaimStorageReward { entry_height }; - Transaction::new(from_keypair, &[], &id(), &program, recent_blockhash, 0) + Transaction::new_signed(from_keypair, &[], &id(), &program, recent_blockhash, 0) } } diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index dd43d52a92..22f7a73fcb 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -1047,7 +1047,7 @@ mod tests { let mut error_counters = ErrorCounters::default(); let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; - let tx = Transaction::new_with_instructions::( + let tx = Transaction::new_with_compiled_instructions::( &[], &[], Hash::default(), @@ -1071,7 +1071,7 @@ mod tests { let keypair = Keypair::new(); let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1103,7 +1103,7 @@ mod tests { accounts.push((key1, account)); let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1131,7 +1131,7 @@ mod tests { accounts.push((key0, account)); let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1166,7 +1166,7 @@ mod tests { accounts.push((key1, account)); let instructions = vec![CompiledInstruction::new(0, &(), vec![0, 1])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[key1], Hash::default(), @@ -1238,7 +1238,7 @@ mod tests { accounts.push((key6, account)); let instructions = vec![CompiledInstruction::new(0, &(), vec![0])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1272,7 +1272,7 @@ mod tests { accounts.push((key1, account)); let instructions = vec![CompiledInstruction::new(0, &(), vec![0])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1305,7 +1305,7 @@ mod tests { accounts.push((key1, account)); let instructions = vec![CompiledInstruction::new(0, &(), vec![0])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1354,7 +1354,7 @@ mod tests { CompiledInstruction::new(0, &(), vec![0]), CompiledInstruction::new(1, &(), vec![0]), ]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[], Hash::default(), @@ -1398,7 +1398,7 @@ mod tests { let instructions = vec![CompiledInstruction::new(0, &(), vec![0, 1])]; // Simulate pay-to-self transaction, which loads the same account twice - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&keypair], &[pubkey], Hash::default(), diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 5d414ba1e8..c3a9fdd253 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -939,7 +939,7 @@ mod tests { }, ]; - let t1 = Transaction::new_with_instructions( + let t1 = Transaction::new_with_compiled_instructions( &[&mint_keypair], &[key1, key2], genesis_block.hash(), diff --git a/sdk/src/loader_transaction.rs b/sdk/src/loader_transaction.rs index 7ca8f9e9f8..13a44992aa 100644 --- a/sdk/src/loader_transaction.rs +++ b/sdk/src/loader_transaction.rs @@ -18,7 +18,7 @@ impl LoaderTransaction { fee: u64, ) -> Transaction { let instruction = LoaderInstruction::Write { offset, bytes }; - Transaction::new( + Transaction::new_signed( from_keypair, &[], loader, @@ -35,7 +35,7 @@ impl LoaderTransaction { fee: u64, ) -> Transaction { let instruction = LoaderInstruction::Finalize; - Transaction::new( + Transaction::new_signed( from_keypair, &[], loader, diff --git a/sdk/src/system_transaction.rs b/sdk/src/system_transaction.rs index d2337c426e..12625d6422 100644 --- a/sdk/src/system_transaction.rs +++ b/sdk/src/system_transaction.rs @@ -25,7 +25,7 @@ impl SystemTransaction { space, program_id: *program_id, }; - Transaction::new( + Transaction::new_signed( from_keypair, &[*to], &system_program::id(), @@ -64,7 +64,7 @@ impl SystemTransaction { let assign = SystemInstruction::Assign { program_id: *program_id, }; - Transaction::new( + Transaction::new_signed( from_keypair, &[], &system_program::id(), @@ -82,7 +82,7 @@ impl SystemTransaction { fee: u64, ) -> Transaction { let move_lamports = SystemInstruction::Move { lamports }; - Transaction::new( + Transaction::new_signed( from_keypair, &[*to], &system_program::id(), @@ -108,7 +108,7 @@ impl SystemTransaction { .collect(); let to_keys: Vec<_> = moves.iter().map(|(to_key, _)| *to_key).collect(); - Transaction::new_with_instructions( + Transaction::new_with_compiled_instructions( &[from], &to_keys, recent_blockhash, diff --git a/sdk/src/transaction.rs b/sdk/src/transaction.rs index 602769c2f1..53d851c197 100644 --- a/sdk/src/transaction.rs +++ b/sdk/src/transaction.rs @@ -167,7 +167,7 @@ pub struct Transaction { } impl Transaction { - pub fn new( + pub fn new_signed( from_keypair: &T, transaction_keys: &[Pubkey], program_id: &Pubkey, @@ -212,7 +212,7 @@ impl Transaction { /// * `fee` - The transaction fee. /// * `program_ids` - The keys that identify programs used in the `instruction` vector. /// * `instructions` - Instructions that will be executed atomically. - pub fn new_with_instructions( + pub fn new_with_compiled_instructions( from_keypairs: &[&T], keys: &[Pubkey], recent_blockhash: Hash, @@ -500,7 +500,7 @@ mod tests { CompiledInstruction::new(0, &(), vec![0, 1]), CompiledInstruction::new(1, &(), vec![0, 2]), ]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&key], &[key1, key2], Hash::default(), @@ -535,7 +535,7 @@ mod tests { fn test_refs_invalid_program_id() { let key = Keypair::new(); let instructions = vec![CompiledInstruction::new(1, &(), vec![])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&key], &[], Hash::default(), @@ -549,7 +549,7 @@ mod tests { fn test_refs_invalid_account() { let key = Keypair::new(); let instructions = vec![CompiledInstruction::new(0, &(), vec![1])]; - let tx = Transaction::new_with_instructions( + let tx = Transaction::new_with_compiled_instructions( &[&key], &[], Hash::default(), @@ -566,7 +566,7 @@ mod tests { let keypair = Keypair::new(); let program_id = Pubkey::new(&[4; 32]); let to = Pubkey::new(&[5; 32]); - let tx = Transaction::new( + let tx = Transaction::new_signed( &keypair, &[keypair.pubkey(), to], &program_id, @@ -585,7 +585,7 @@ mod tests { let keypair = Keypair::new(); let program_id = Pubkey::new(&[4; 32]); let to = Pubkey::new(&[5; 32]); - let tx = Transaction::new( + let tx = Transaction::new_signed( &keypair, &[keypair.pubkey(), to], &program_id, @@ -631,7 +631,7 @@ mod tests { 2, 2, 2, ]); - let tx = Transaction::new( + let tx = Transaction::new_signed( &keypair, &[to], &program_id,