Remove Instruction wrapper structs and name functions after enum fields

This commit is contained in:
Greg Fitzgerald
2019-04-03 09:45:57 -06:00
committed by Grimes
parent 867f6f107b
commit 35298e01a8
53 changed files with 835 additions and 922 deletions

View File

@ -507,7 +507,7 @@ mod tests {
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::instruction::InstructionError;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use std::sync::mpsc::channel;
use std::thread::sleep;
@ -593,7 +593,7 @@ 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_user_account(
let fund_tx = system_transaction::create_user_account(
&mint_keypair,
&keypair.pubkey(),
2,
@ -604,16 +604,17 @@ mod tests {
// good tx
let to = Pubkey::new_rand();
let tx = SystemTransaction::new_user_account(&mint_keypair, &to, 1, start_hash, 0);
let tx = system_transaction::create_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_user_account(&keypair, &to2, 2, start_hash, 0);
let tx_no_ver =
system_transaction::create_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_user_account(&keypair, &to3, 1, start_hash, 0);
let tx_anf = system_transaction::create_user_account(&keypair, &to3, 1, start_hash, 0);
// send 'em over
let packets = to_packets(&[tx_no_ver, tx_anf, tx]);
@ -676,7 +677,7 @@ mod tests {
// Process a batch that includes a transaction that receives two lamports.
let alice = Keypair::new();
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&alice.pubkey(),
2,
@ -690,7 +691,7 @@ mod tests {
.unwrap();
// Process a second batch that spends one of those lamports.
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&alice,
&mint_keypair.pubkey(),
1,
@ -783,8 +784,8 @@ mod tests {
let pubkey = Pubkey::new_rand();
let transactions = vec![
SystemTransaction::new_transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
SystemTransaction::new_transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
system_transaction::transfer(&mint_keypair, &pubkey, 1, genesis_block.hash(), 0),
];
let mut results = vec![Ok(()), Ok(())];
@ -820,7 +821,7 @@ mod tests {
let bank = Arc::new(Bank::new(&genesis_block));
let pubkey = Pubkey::new_rand();
let transactions = vec![SystemTransaction::new_transfer(
let transactions = vec![system_transaction::transfer(
&mint_keypair,
&pubkey,
1,
@ -873,7 +874,7 @@ mod tests {
assert_eq!(done, true);
let transactions = vec![SystemTransaction::new_transfer(
let transactions = vec![system_transaction::transfer(
&mint_keypair,
&pubkey,
2,

View File

@ -172,7 +172,7 @@ mod test {
use serde_json::Value;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use std::collections::HashSet;
#[test]
@ -184,9 +184,9 @@ mod test {
let keypair0 = Keypair::new();
let keypair1 = Keypair::new();
let tx0 =
SystemTransaction::new_transfer(&keypair0, &keypair1.pubkey(), 1, Hash::default(), 0);
system_transaction::transfer(&keypair0, &keypair1.pubkey(), 1, Hash::default(), 0);
let tx1 =
SystemTransaction::new_transfer(&keypair1, &keypair0.pubkey(), 2, Hash::default(), 0);
system_transaction::transfer(&keypair1, &keypair0.pubkey(), 2, Hash::default(), 0);
let serialized_tx0 = serialize(&tx0).unwrap();
let serialized_tx1 = serialize(&tx1).unwrap();
let entry = Entry::new(&Hash::default(), 1, vec![tx0, tx1]);

View File

@ -115,7 +115,7 @@ mod test {
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use std::sync::mpsc::channel;
#[test]
@ -141,8 +141,13 @@ mod test {
let keypair = Keypair::new();
let mut blockhash = entries[3].hash;
let tx =
SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 1, Hash::default(), 0);
let tx = system_transaction::create_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

@ -233,7 +233,7 @@ mod tests {
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::transaction::TransactionError;
fn fill_blocktree_slot_with_ticks(
@ -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_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair.pubkey(),
1,
@ -453,7 +453,7 @@ mod tests {
for _ in 0..3 {
// Transfer one token from the mint to a random account
let keypair = Keypair::new();
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair.pubkey(),
1,
@ -467,8 +467,13 @@ mod tests {
// Add a second Transaction that will produce a
// InstructionError<0, ResultWithNegativeLamports> error when processed
let keypair2 = Keypair::new();
let tx =
SystemTransaction::new_user_account(&keypair, &keypair2.pubkey(), 42, blockhash, 0);
let tx = system_transaction::create_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);
@ -545,7 +550,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_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair1.pubkey(),
2,
@ -553,7 +558,7 @@ mod tests {
0,
);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair2.pubkey(),
2,
@ -583,7 +588,7 @@ mod tests {
let entry_1_to_mint = next_entry(
&bank.last_blockhash(),
1,
vec![SystemTransaction::new_user_account(
vec![system_transaction::create_user_account(
&keypair1,
&mint_keypair.pubkey(),
1,
@ -596,14 +601,14 @@ mod tests {
&entry_1_to_mint.hash,
1,
vec![
SystemTransaction::new_user_account(
system_transaction::create_user_account(
&keypair2,
&keypair3.pubkey(),
2,
bank.last_blockhash(),
0,
), // should be fine
SystemTransaction::new_user_account(
system_transaction::create_user_account(
&keypair1,
&mint_keypair.pubkey(),
2,
@ -642,14 +647,14 @@ mod tests {
&bank.last_blockhash(),
1,
vec![
SystemTransaction::new_user_account(
system_transaction::create_user_account(
&keypair1,
&mint_keypair.pubkey(),
1,
bank.last_blockhash(),
0,
),
SystemTransaction::new_transfer(
system_transaction::transfer(
&keypair4,
&keypair4.pubkey(),
1,
@ -663,14 +668,14 @@ mod tests {
&entry_1_to_mint.hash,
1,
vec![
SystemTransaction::new_user_account(
system_transaction::create_user_account(
&keypair2,
&keypair3.pubkey(),
2,
bank.last_blockhash(),
0,
), // should be fine
SystemTransaction::new_user_account(
system_transaction::create_user_account(
&keypair1,
&mint_keypair.pubkey(),
2,
@ -715,7 +720,7 @@ mod tests {
let keypair4 = Keypair::new();
//load accounts
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair1.pubkey(),
1,
@ -723,7 +728,7 @@ mod tests {
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair2.pubkey(),
1,
@ -734,7 +739,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_user_account(
let tx = system_transaction::create_user_account(
&keypair1,
&keypair3.pubkey(),
1,
@ -742,7 +747,7 @@ mod tests {
0,
);
let entry_1 = next_entry(&blockhash, 1, vec![tx]);
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&keypair2,
&keypair4.pubkey(),
1,
@ -766,7 +771,7 @@ mod tests {
let keypair4 = Keypair::new();
//load accounts
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair1.pubkey(),
1,
@ -774,7 +779,7 @@ mod tests {
0,
);
assert_eq!(bank.process_transaction(&tx), Ok(()));
let tx = SystemTransaction::new_user_account(
let tx = system_transaction::create_user_account(
&mint_keypair,
&keypair2.pubkey(),
1,
@ -790,10 +795,10 @@ mod tests {
// ensure bank can process 2 entries that do not have a common account and tick is registered
let tx =
SystemTransaction::new_user_account(&keypair2, &keypair3.pubkey(), 1, blockhash, 0);
system_transaction::create_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_user_account(
let tx = system_transaction::create_user_account(
&keypair1,
&keypair4.pubkey(),
1,
@ -809,7 +814,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_user_account(
let tx = system_transaction::create_user_account(
&keypair2,
&keypair3.pubkey(),
1,

View File

@ -97,7 +97,7 @@ mod tests {
use ring::signature::Ed25519KeyPair;
use solana_sdk::hash::{hash, Hash, Hasher};
use solana_sdk::signature::KeypairUtil;
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use std::fs::remove_file;
use std::fs::File;
use std::io::Read;
@ -124,7 +124,7 @@ mod tests {
Entry::new_mut(
&mut id,
&mut num_hashes,
vec![SystemTransaction::new_user_account(
vec![system_transaction::create_user_account(
&keypair,
&keypair.pubkey(),
1,

View File

@ -12,7 +12,7 @@ use crate::poh_service::PohServiceConfig;
use solana_client::thin_client::create_client;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::timing::{
duration_as_ms, DEFAULT_TICKS_PER_SLOT, NUM_CONSECUTIVE_LEADER_SLOTS, NUM_TICKS_PER_SECOND,
};
@ -37,7 +37,7 @@ pub fn spend_and_verify_all_nodes(
.poll_get_balance(&funding_keypair.pubkey())
.expect("balance in source");
assert!(bal > 0);
let mut transaction = SystemTransaction::new_transfer(
let mut transaction = system_transaction::transfer(
&funding_keypair,
&random_keypair.pubkey(),
1,
@ -63,7 +63,7 @@ pub fn send_many_transactions(node: &ContactInfo, funding_keypair: &Keypair, num
.poll_get_balance(&funding_keypair.pubkey())
.expect("balance in source");
assert!(bal > 0);
let mut transaction = SystemTransaction::new_transfer(
let mut transaction = system_transaction::transfer(
&funding_keypair,
&random_keypair.pubkey(),
1,
@ -183,7 +183,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
}
let random_keypair = Keypair::new();
let mut transaction = SystemTransaction::new_transfer(
let mut transaction = system_transaction::transfer(
&funding_keypair,
&random_keypair.pubkey(),
1,

View File

@ -8,7 +8,7 @@ use crate::result::Result;
use bincode::{deserialize, serialized_size};
use chrono::prelude::Utc;
use rayon::prelude::*;
use solana_budget_api::budget_instruction::BudgetInstruction;
use solana_budget_api::budget_instruction;
use solana_sdk::hash::{Hash, Hasher};
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::transaction::Transaction;
@ -380,7 +380,7 @@ pub fn make_tiny_test_entries_from_hash(start: &Hash, num: usize) -> Vec<Entry>
let mut num_hashes = 0;
(0..num)
.map(|_| {
let ix = BudgetInstruction::new_apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
let ix = budget_instruction::apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
let tx = Transaction::new_signed_instructions(&[&keypair], vec![ix], *start);
Entry::new_mut(&mut hash, &mut num_hashes, vec![tx])
})
@ -399,7 +399,7 @@ pub fn make_large_test_entries(num_entries: usize) -> Vec<Entry> {
let keypair = Keypair::new();
let pubkey = keypair.pubkey();
let ix = BudgetInstruction::new_apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
let ix = budget_instruction::apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
let tx = Transaction::new_signed_instructions(&[&keypair], vec![ix], one);
let serialized_size = serialized_size(&tx).unwrap();
@ -450,31 +450,31 @@ mod tests {
use crate::packet::{to_blobs, BLOB_DATA_SIZE, PACKET_DATA_SIZE};
use solana_sdk::hash::hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_vote_api::vote_instruction::{Vote, VoteInstruction};
use solana_sdk::system_transaction;
use solana_vote_api::vote_instruction::{self, Vote};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
fn create_sample_payment(keypair: &Keypair, hash: Hash) -> Transaction {
let pubkey = keypair.pubkey();
let ixs = BudgetInstruction::new_payment(&pubkey, &pubkey, 1);
let ixs = budget_instruction::payment(&pubkey, &pubkey, 1);
Transaction::new_signed_instructions(&[keypair], ixs, hash)
}
fn create_sample_timestamp(keypair: &Keypair, hash: Hash) -> Transaction {
let pubkey = keypair.pubkey();
let ix = BudgetInstruction::new_apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
let ix = budget_instruction::apply_timestamp(&pubkey, &pubkey, &pubkey, Utc::now());
Transaction::new_signed_instructions(&[keypair], vec![ix], hash)
}
fn create_sample_signature(keypair: &Keypair, hash: Hash) -> Transaction {
let pubkey = keypair.pubkey();
let ix = BudgetInstruction::new_apply_signature(&pubkey, &pubkey, &pubkey);
let ix = budget_instruction::apply_signature(&pubkey, &pubkey, &pubkey);
Transaction::new_signed_instructions(&[keypair], vec![ix], hash)
}
fn create_sample_vote(keypair: &Keypair, hash: Hash) -> Transaction {
let pubkey = keypair.pubkey();
let ix = VoteInstruction::new_vote(&pubkey, Vote::new(1));
let ix = vote_instruction::vote(&pubkey, Vote::new(1));
Transaction::new_signed_instructions(&[keypair], vec![ix], hash)
}
@ -494,8 +494,8 @@ mod tests {
// First, verify entries
let keypair = Keypair::new();
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 tx0 = system_transaction::create_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx1 = system_transaction::create_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_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx = system_transaction::create_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_user_account(&keypair, &keypair.pubkey(), 0, zero, 0);
let tx = system_transaction::create_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

@ -25,10 +25,10 @@ use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::timing::timestamp;
use solana_sdk::transaction::Transaction;
use solana_vote_api::vote_instruction::{Vote, VoteInstruction};
use solana_vote_api::vote_instruction::{self, Vote};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver};
@ -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_user_account(
let transfer_tx = system_transaction::create_user_account(
&lamport_source,
&active_keypair.pubkey(),
stake,
@ -332,7 +332,7 @@ pub fn make_active_set_entries(
let voting_keypair = Keypair::new();
let vote_account_id = voting_keypair.pubkey();
let new_vote_account_ixs = VoteInstruction::new_account(
let new_vote_account_ixs = vote_instruction::create_account(
&active_keypair.pubkey(),
&vote_account_id,
stake.saturating_sub(2),
@ -345,7 +345,7 @@ pub fn make_active_set_entries(
let new_vote_account_entry = next_entry_mut(&mut last_entry_hash, 1, vec![new_vote_account_tx]);
// 3) Create vote entry
let vote_ix = VoteInstruction::new_vote(&voting_keypair.pubkey(), Vote::new(slot_to_vote_on));
let vote_ix = vote_instruction::vote(&voting_keypair.pubkey(), Vote::new(slot_to_vote_on));
let vote_tx =
Transaction::new_signed_instructions(&[&voting_keypair], vec![vote_ix], *blockhash);
let vote_entry = next_entry_mut(&mut last_entry_hash, 1, vec![vote_tx]);

View File

@ -11,11 +11,11 @@ use solana_client::thin_client::ThinClient;
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::timing::DEFAULT_SLOTS_PER_EPOCH;
use solana_sdk::timing::DEFAULT_TICKS_PER_SLOT;
use solana_sdk::transaction::Transaction;
use solana_vote_api::vote_instruction::VoteInstruction;
use solana_vote_api::vote_instruction;
use solana_vote_api::vote_state::VoteState;
use std::collections::HashMap;
use std::fs::remove_dir_all;
@ -296,7 +296,7 @@ impl LocalCluster {
) -> u64 {
trace!("getting leader blockhash");
let blockhash = client.get_recent_blockhash().unwrap();
let mut tx = SystemTransaction::new_user_account(
let mut tx = system_transaction::create_user_account(
&source_keypair,
dest_pubkey,
lamports,
@ -328,8 +328,11 @@ impl LocalCluster {
// Create the vote account if necessary
if client.poll_get_balance(&vote_account_pubkey).unwrap_or(0) == 0 {
// 1) Create vote account
let instructions =
VoteInstruction::new_account(&from_account.pubkey(), &vote_account_pubkey, amount);
let instructions = vote_instruction::create_account(
&from_account.pubkey(),
&vote_account_pubkey,
amount,
);
let mut transaction = Transaction::new_signed_instructions(
&[from_account.as_ref()],
instructions,
@ -345,7 +348,7 @@ impl LocalCluster {
// 2) Set delegate for new vote account
let vote_instruction =
VoteInstruction::new_delegate_stake(&vote_account_pubkey, &delegate_id);
vote_instruction::delegate_stake(&vote_account_pubkey, &delegate_id);
let mut transaction = Transaction::new_signed_instructions(
&[vote_account],

View File

@ -573,7 +573,7 @@ mod tests {
use rand::Rng;
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use std::io;
use std::io::Write;
use std::net::{Ipv4Addr, SocketAddr, UdpSocket};
@ -612,7 +612,7 @@ mod tests {
fn test_to_packets() {
let keypair = Keypair::new();
let hash = Hash::new(&[1; 32]);
let tx = SystemTransaction::new_user_account(&keypair, &keypair.pubkey(), 1, hash, 0);
let tx = system_transaction::create_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

@ -21,7 +21,7 @@ use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::KeypairUtil;
use solana_sdk::timing::{self, duration_as_ms};
use solana_sdk::transaction::Transaction;
use solana_vote_api::vote_instruction::{Vote, VoteInstruction};
use solana_vote_api::vote_instruction::{self, Vote};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
use std::sync::{Arc, Mutex, RwLock};
@ -296,7 +296,7 @@ impl ReplayStage {
T: 'static + KeypairUtil + Send + Sync,
{
if let Some(ref voting_keypair) = voting_keypair {
let vote_ix = VoteInstruction::new_vote(&vote_account, Vote::new(bank.slot()));
let vote_ix = vote_instruction::vote(&vote_account, Vote::new(bank.slot()));
let vote_tx = Transaction::new_signed_instructions(
&[voting_keypair.as_ref()],
vec![vote_ix],
@ -635,7 +635,7 @@ mod test {
ledger_writer_sender,
);
let vote_ix = VoteInstruction::new_vote(&voting_keypair.pubkey(), Vote::new(0));
let vote_ix = vote_instruction::vote(&voting_keypair.pubkey(), Vote::new(0));
let vote_tx = Transaction::new_signed_instructions(
&[voting_keypair.as_ref()],
vec![vote_ix],

View File

@ -22,9 +22,9 @@ use solana_client::thin_client::{create_client, ThinClient};
use solana_drone::drone::{request_airdrop_transaction, DRONE_PORT};
use solana_sdk::hash::{Hash, Hasher};
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::transaction::Transaction;
use solana_storage_api::storage_instruction::StorageInstruction;
use solana_storage_api::storage_instruction;
use std::fs::File;
use std::io;
use std::io::BufReader;
@ -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_account(
let tx = system_transaction::create_account(
keypair,
&storage_keypair.pubkey(),
blockhash,
@ -455,7 +455,7 @@ impl Replicator {
);
Self::get_airdrop_lamports(&client, &self.keypair, &self.cluster_entrypoint);
let ix = StorageInstruction::new_mining_proof(
let ix = storage_instruction::mining_proof(
&self.storage_keypair.pubkey(),
self.hash,
self.slot,

View File

@ -454,7 +454,7 @@ mod tests {
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use std::thread;
fn start_rpc_handler_with_tx(pubkey: &Pubkey) -> (MetaIoHandler<Meta>, Meta, Hash, Keypair) {
@ -463,7 +463,7 @@ mod tests {
let exit = Arc::new(AtomicBool::new(false));
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_transfer(&alice, pubkey, 20, blockhash, 0);
let tx = system_transaction::transfer(&alice, pubkey, 20, blockhash, 0);
bank.process_transaction(&tx).expect("process transaction");
let request_processor = Arc::new(RwLock::new(JsonRpcRequestProcessor::new(
@ -503,7 +503,7 @@ mod tests {
);
thread::spawn(move || {
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
bank.process_transaction(&tx).expect("process transaction");
})
.join()
@ -575,7 +575,7 @@ mod tests {
fn test_rpc_confirm_tx() {
let bob_pubkey = Pubkey::new_rand();
let (io, meta, blockhash, alice) = start_rpc_handler_with_tx(&bob_pubkey);
let tx = SystemTransaction::new_transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"confirmTransaction","params":["{}"]}}"#,
@ -594,7 +594,7 @@ mod tests {
fn test_rpc_get_signature_status() {
let bob_pubkey = Pubkey::new_rand();
let (io, meta, blockhash, alice) = start_rpc_handler_with_tx(&bob_pubkey);
let tx = SystemTransaction::new_transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
@ -609,7 +609,7 @@ mod tests {
assert_eq!(expected, result);
// Test getSignatureStatus request on unprocessed tx
let tx = SystemTransaction::new_transfer(&alice, &bob_pubkey, 10, blockhash, 0);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 10, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"getSignatureStatus","params":["{}"]}}"#,
tx.signatures[0]
@ -716,13 +716,8 @@ mod tests {
#[test]
fn test_rpc_verify_signature() {
let tx = SystemTransaction::new_transfer(
&Keypair::new(),
&Pubkey::new_rand(),
20,
hash(&[0]),
0,
);
let tx =
system_transaction::transfer(&Keypair::new(), &Pubkey::new_rand(), 20, hash(&[0]), 0);
assert_eq!(
verify_signature(&tx.signatures[0].to_string()).unwrap(),
tx.signatures[0]

View File

@ -227,12 +227,12 @@ mod tests {
use jsonrpc_core::Response;
use jsonrpc_pubsub::{PubSubHandler, Session};
use solana_budget_api;
use solana_budget_api::budget_instruction::BudgetInstruction;
use solana_budget_api::budget_instruction;
use solana_runtime::bank::{self, Bank};
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::transaction::Transaction;
use std::thread::sleep;
use std::time::Duration;
@ -270,7 +270,7 @@ mod tests {
let rpc = RpcSolPubSubImpl::default();
// Test signature subscriptions
let tx = SystemTransaction::new_transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let session = create_session();
let (subscriber, _id_receiver, mut receiver) =
@ -302,7 +302,7 @@ mod tests {
let rpc = RpcSolPubSubImpl::default();
io.extend_with(rpc.to_delegate());
let tx = SystemTransaction::new_transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let tx = system_transaction::transfer(&alice, &bob_pubkey, 20, blockhash, 0);
let req = format!(
r#"{{"jsonrpc":"2.0","id":1,"method":"signatureSubscribe","params":["{}"]}}"#,
tx.signatures[0].to_string()
@ -354,11 +354,16 @@ 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_user_account(&alice, &contract_funds.pubkey(), 51, blockhash, 0);
let tx = system_transaction::create_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(
let ixs = budget_instruction::when_signed(
&contract_funds.pubkey(),
&bob_pubkey,
&contract_state.pubkey(),
@ -391,10 +396,11 @@ mod tests {
assert_eq!(serde_json::to_string(&expected).unwrap(), response);
}
let tx = SystemTransaction::new_user_account(&alice, &witness.pubkey(), 1, blockhash, 0);
let tx =
system_transaction::create_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(
let ix = budget_instruction::apply_signature(
&witness.pubkey(),
&contract_state.pubkey(),
&bob_pubkey,

View File

@ -202,7 +202,7 @@ mod tests {
use solana_budget_api;
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use tokio::prelude::{Async, Stream};
#[test]
@ -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_account(
let tx = system_transaction::create_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_account(
let tx = system_transaction::create_account(
&mint_keypair,
&alice.pubkey(),
blockhash,
@ -302,7 +302,7 @@ mod tests {
let bank = Bank::new(&genesis_block);
let alice = Keypair::new();
let blockhash = bank.last_blockhash();
let tx = SystemTransaction::new_transfer(&mint_keypair, &alice.pubkey(), 20, blockhash, 0);
let tx = system_transaction::transfer(&mint_keypair, &alice.pubkey(), 20, blockhash, 0);
let signature = tx.signatures[0];
bank.process_transaction(&tx).unwrap();

View File

@ -16,9 +16,9 @@ use solana_client::thin_client::{create_client_with_timeout, ThinClient};
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::transaction::Transaction;
use solana_storage_api::storage_instruction::StorageInstruction;
use solana_storage_api::storage_instruction::{self, StorageInstruction};
use std::collections::HashSet;
use std::io;
use std::mem::size_of;
@ -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_account(
let tx = system_transaction::create_account(
keypair,
&storage_keypair.pubkey(),
blockhash,
@ -318,7 +318,7 @@ impl StorageStage {
let mut seed = [0u8; 32];
let signature = keypair.sign(&entry_id.as_ref());
let ix = StorageInstruction::new_advertise_recent_blockhash(
let ix = storage_instruction::advertise_recent_blockhash(
&keypair.pubkey(),
entry_id,
entry_height,
@ -643,7 +643,7 @@ mod tests {
}
let keypair = Keypair::new();
let mining_proof_ix = StorageInstruction::new_mining_proof(
let mining_proof_ix = storage_instruction::mining_proof(
&keypair.pubkey(),
Hash::default(),
0,

View File

@ -3,14 +3,14 @@ use solana_sdk::instruction::CompiledInstruction;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::system_program;
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::system_transaction;
use solana_sdk::transaction::Transaction;
pub fn test_tx() -> Transaction {
let keypair1 = Keypair::new();
let pubkey1 = keypair1.pubkey();
let zero = Hash::default();
SystemTransaction::new_user_account(&keypair1, &pubkey1, 42, zero, 0)
system_transaction::create_user_account(&keypair1, &pubkey1, 42, zero, 0)
}
pub fn test_multisig_tx() -> Transaction {
@ -20,11 +20,15 @@ pub fn test_multisig_tx() -> Transaction {
let lamports = 5;
let blockhash = Hash::default();
let system_instruction = SystemInstruction::Transfer { lamports };
let transfer_instruction = SystemInstruction::Transfer { lamports };
let program_ids = vec![system_program::id(), solana_budget_api::id()];
let instructions = vec![CompiledInstruction::new(0, &system_instruction, vec![0, 1])];
let instructions = vec![CompiledInstruction::new(
0,
&transfer_instruction,
vec![0, 1],
)];
Transaction::new_with_compiled_instructions(
&keypairs,

View File

@ -110,7 +110,7 @@ pub mod tests {
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::transaction::Transaction;
use solana_vote_api::vote_instruction::{Vote, VoteInstruction};
use solana_vote_api::vote_instruction::{self, Vote};
fn process_instructions<T: KeypairUtil>(bank: &Bank, keypairs: &[&T], ixs: Vec<Instruction>) {
let blockhash = bank.last_blockhash();
@ -124,7 +124,7 @@ pub mod tests {
bank: &Bank,
lamports: u64,
) {
let ixs = VoteInstruction::new_account(&from_keypair.pubkey(), voting_pubkey, lamports);
let ixs = vote_instruction::create_account(&from_keypair.pubkey(), voting_pubkey, lamports);
process_instructions(bank, &[from_keypair], ixs);
}
@ -137,16 +137,13 @@ pub mod tests {
) {
let voting_pubkey = voting_keypair.pubkey();
let mut ixs =
VoteInstruction::new_account(&from_keypair.pubkey(), &voting_pubkey, lamports);
ixs.push(VoteInstruction::new_delegate_stake(
&voting_pubkey,
delegate,
));
vote_instruction::create_account(&from_keypair.pubkey(), &voting_pubkey, lamports);
ixs.push(vote_instruction::delegate_stake(&voting_pubkey, delegate));
process_instructions(bank, &[from_keypair, voting_keypair], ixs);
}
pub fn push_vote<T: KeypairUtil>(voting_keypair: &T, bank: &Bank, slot: u64) {
let ix = VoteInstruction::new_vote(&voting_keypair.pubkey(), Vote::new(slot));
let ix = vote_instruction::vote(&voting_keypair.pubkey(), Vote::new(slot));
process_instructions(bank, &[voting_keypair], vec![ix]);
}
@ -159,8 +156,8 @@ pub mod tests {
) {
let voting_pubkey = voting_keypair.pubkey();
let mut ixs =
VoteInstruction::new_account(&from_keypair.pubkey(), &voting_pubkey, lamports);
ixs.push(VoteInstruction::new_vote(&voting_pubkey, Vote::new(slot)));
vote_instruction::create_account(&from_keypair.pubkey(), &voting_pubkey, lamports);
ixs.push(vote_instruction::vote(&voting_pubkey, Vote::new(slot)));
process_instructions(bank, &[from_keypair, voting_keypair], ixs);
}
}