Add unit-test-friendly VoteSignerProxy constructor

This commit is contained in:
Greg Fitzgerald 2019-01-25 19:47:05 -07:00
parent 1e43fb587e
commit 1bae87d4b3
13 changed files with 62 additions and 141 deletions

View File

@ -165,7 +165,6 @@ pub mod tests {
use bincode::serialize; use bincode::serialize;
use solana_sdk::hash::hash; use solana_sdk::hash::hash;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use std::sync::Arc; use std::sync::Arc;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
@ -195,8 +194,7 @@ pub mod tests {
// Create new validator to vote // Create new validator to vote
let validator_keypair = Arc::new(Keypair::new()); let validator_keypair = Arc::new(Keypair::new());
let last_id = ids[i]; let last_id = ids[i];
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&validator_keypair);
VoteSignerProxy::new(&validator_keypair, Box::new(LocalVoteSigner::default()));
// Give the validator some tokens // Give the validator some tokens
bank.transfer(2, &mint_keypair, validator_keypair.pubkey(), last_id) bank.transfer(2, &mint_keypair, validator_keypair.pubkey(), last_id)

View File

@ -535,7 +535,6 @@ mod tests {
use crate::tvu::TvuReturnType; use crate::tvu::TvuReturnType;
use crate::vote_signer_proxy::VoteSignerProxy; use crate::vote_signer_proxy::VoteSignerProxy;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use std::cmp; use std::cmp;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
use std::net::UdpSocket; use std::net::UdpSocket;
@ -559,7 +558,7 @@ mod tests {
let last_id = bank.last_id(); let last_id = bank.last_id();
let keypair = Arc::new(keypair); let keypair = Arc::new(keypair);
let signer = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer = VoteSignerProxy::new_local(&keypair);
let v = Fullnode::new_with_bank( let v = Fullnode::new_with_bank(
keypair, keypair,
Some(Arc::new(signer)), Some(Arc::new(signer)),
@ -602,7 +601,7 @@ mod tests {
let entry_height = 0; let entry_height = 0;
let last_id = bank.last_id(); let last_id = bank.last_id();
let keypair = Arc::new(keypair); let keypair = Arc::new(keypair);
let signer = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer = VoteSignerProxy::new_local(&keypair);
Fullnode::new_with_bank( Fullnode::new_with_bank(
keypair, keypair,
Some(Arc::new(signer)), Some(Arc::new(signer)),
@ -675,10 +674,7 @@ mod tests {
); );
let bootstrap_leader_keypair = Arc::new(bootstrap_leader_keypair); let bootstrap_leader_keypair = Arc::new(bootstrap_leader_keypair);
let signer = VoteSignerProxy::new( let signer = VoteSignerProxy::new_local(&bootstrap_leader_keypair);
&bootstrap_leader_keypair,
Box::new(LocalVoteSigner::default()),
);
// Start up the leader // Start up the leader
let mut bootstrap_leader = Fullnode::new( let mut bootstrap_leader = Fullnode::new(
bootstrap_leader_node, bootstrap_leader_node,
@ -783,10 +779,7 @@ mod tests {
{ {
// Test that a node knows to transition to a validator based on parsing the ledger // Test that a node knows to transition to a validator based on parsing the ledger
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&bootstrap_leader_keypair);
&bootstrap_leader_keypair,
Box::new(LocalVoteSigner::default()),
);
let bootstrap_leader = Fullnode::new( let bootstrap_leader = Fullnode::new(
bootstrap_leader_node, bootstrap_leader_node,
&bootstrap_leader_ledger_path, &bootstrap_leader_ledger_path,
@ -895,8 +888,7 @@ mod tests {
Some(bootstrap_height), Some(bootstrap_height),
); );
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&validator_keypair);
VoteSignerProxy::new(&validator_keypair, Box::new(LocalVoteSigner::default()));
// Start the validator // Start the validator
let validator = Fullnode::new( let validator = Fullnode::new(
validator_node, validator_node,

View File

@ -15,7 +15,6 @@ use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program::{self, Vote, VoteProgram}; use solana_sdk::vote_program::{self, Vote, VoteProgram};
use solana_sdk::vote_transaction::VoteTransaction; use solana_sdk::vote_transaction::VoteTransaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use std::io::Cursor; use std::io::Cursor;
use std::sync::Arc; use std::sync::Arc;
@ -495,7 +494,7 @@ pub fn make_active_set_entries(
let mut last_entry_id = transfer_entry.id; let mut last_entry_id = transfer_entry.id;
// 2) Create and register the vote account // 2) Create and register the vote account
let vote_signer = VoteSignerProxy::new(active_keypair, Box::new(LocalVoteSigner::default())); let vote_signer = VoteSignerProxy::new_local(active_keypair);
let vote_account_id: Pubkey = vote_signer.vote_account; let vote_account_id: Pubkey = vote_signer.vote_account;
let new_vote_account_tx = let new_vote_account_tx =
@ -539,7 +538,6 @@ mod tests {
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use std::hash::Hash as StdHash; use std::hash::Hash as StdHash;
use std::iter::FromIterator; use std::iter::FromIterator;
use std::sync::Arc; use std::sync::Arc;
@ -590,10 +588,7 @@ mod tests {
for i in 0..num_validators { for i in 0..num_validators {
let new_validator = Keypair::new(); let new_validator = Keypair::new();
let new_pubkey = new_validator.pubkey(); let new_pubkey = new_validator.pubkey();
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(new_validator));
&Arc::new(new_validator),
Box::new(LocalVoteSigner::default()),
);
validators.push(new_pubkey); validators.push(new_pubkey);
// Give the validator some tokens // Give the validator some tokens
bank.transfer( bank.transfer(
@ -720,8 +715,7 @@ mod tests {
.unwrap(); .unwrap();
// Create a vote account // Create a vote account
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&Arc::new(new_keypair));
VoteSignerProxy::new(&Arc::new(new_keypair), Box::new(LocalVoteSigner::default()));
vote_signer vote_signer
.new_vote_account(&bank, 1 as u64, genesis_block.last_id()) .new_vote_account(&bank, 1 as u64, genesis_block.last_id())
.unwrap(); .unwrap();
@ -742,8 +736,7 @@ mod tests {
.unwrap(); .unwrap();
// Create a vote account // Create a vote account
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&Arc::new(new_keypair));
VoteSignerProxy::new(&Arc::new(new_keypair), Box::new(LocalVoteSigner::default()));
vote_signer vote_signer
.new_vote_account(&bank, 1 as u64, genesis_block.last_id()) .new_vote_account(&bank, 1 as u64, genesis_block.last_id())
.unwrap(); .unwrap();
@ -1005,10 +998,7 @@ mod tests {
for i in 0..num_validators { for i in 0..num_validators {
let new_validator = Keypair::new(); let new_validator = Keypair::new();
let new_pubkey = new_validator.pubkey(); let new_pubkey = new_validator.pubkey();
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(new_validator));
&Arc::new(new_validator),
Box::new(LocalVoteSigner::default()),
);
validators.push(new_pubkey); validators.push(new_pubkey);
// Give the validator some tokens // Give the validator some tokens
bank.transfer( bank.transfer(
@ -1071,10 +1061,7 @@ mod tests {
// window // window
let initial_vote_height = 1; let initial_vote_height = 1;
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(leader_keypair));
&Arc::new(leader_keypair),
Box::new(LocalVoteSigner::default()),
);
// Create a vote account // Create a vote account
vote_signer vote_signer
.new_vote_account(&bank, 1 as u64, genesis_block.last_id()) .new_vote_account(&bank, 1 as u64, genesis_block.last_id())
@ -1221,10 +1208,7 @@ mod tests {
bank.transfer(5, &mint_keypair, validator_id, last_id) bank.transfer(5, &mint_keypair, validator_id, last_id)
.unwrap(); .unwrap();
// Create a vote account // Create a vote account
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(validator_keypair));
&Arc::new(validator_keypair),
Box::new(LocalVoteSigner::default()),
);
vote_signer vote_signer
.new_vote_account(&bank, 1 as u64, genesis_block.last_id()) .new_vote_account(&bank, 1 as u64, genesis_block.last_id())
.unwrap(); .unwrap();
@ -1261,10 +1245,7 @@ mod tests {
.unwrap(); .unwrap();
// Create a vote account // Create a vote account
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(bootstrap_leader_keypair));
&Arc::new(bootstrap_leader_keypair),
Box::new(LocalVoteSigner::default()),
);
vote_signer vote_signer
.new_vote_account(&bank, vote_account_tokens as u64, genesis_block.last_id()) .new_vote_account(&bank, vote_account_tokens as u64, genesis_block.last_id())
.unwrap(); .unwrap();
@ -1387,10 +1368,7 @@ mod tests {
// Create a vote account for the validator // Create a vote account for the validator
bank.transfer(5, &mint_keypair, validator_id, last_id) bank.transfer(5, &mint_keypair, validator_id, last_id)
.unwrap(); .unwrap();
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(validator_keypair));
&Arc::new(validator_keypair),
Box::new(LocalVoteSigner::default()),
);
vote_signer vote_signer
.new_vote_account(&bank, 1 as u64, genesis_block.last_id()) .new_vote_account(&bank, 1 as u64, genesis_block.last_id())
.unwrap(); .unwrap();
@ -1404,10 +1382,7 @@ mod tests {
// Create a vote account for the leader // Create a vote account for the leader
bank.transfer(5, &mint_keypair, bootstrap_leader_id, last_id) bank.transfer(5, &mint_keypair, bootstrap_leader_id, last_id)
.unwrap(); .unwrap();
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&Arc::new(bootstrap_leader_keypair));
&Arc::new(bootstrap_leader_keypair),
Box::new(LocalVoteSigner::default()),
);
vote_signer vote_signer
.new_vote_account(&bank, 1 as u64, genesis_block.last_id()) .new_vote_account(&bank, 1 as u64, genesis_block.last_id())
.unwrap(); .unwrap();

View File

@ -293,7 +293,6 @@ mod test {
use crate::vote_signer_proxy::VoteSignerProxy; use crate::vote_signer_proxy::VoteSignerProxy;
use solana_sdk::hash::Hash; use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
@ -474,10 +473,7 @@ mod test {
let (entry_sender, entry_receiver) = channel(); let (entry_sender, entry_receiver) = channel();
let exit = Arc::new(AtomicBool::new(false)); let exit = Arc::new(AtomicBool::new(false));
let my_keypair = Arc::new(my_keypair); let my_keypair = Arc::new(my_keypair);
let vote_signer = Arc::new(VoteSignerProxy::new( let vote_signer = Arc::new(VoteSignerProxy::new_local(&my_keypair));
&my_keypair,
Box::new(LocalVoteSigner::default()),
));
let (to_leader_sender, _) = channel(); let (to_leader_sender, _) = channel();
let (replay_stage, ledger_writer_recv) = ReplayStage::new( let (replay_stage, ledger_writer_recv) = ReplayStage::new(
my_keypair.clone(), my_keypair.clone(),
@ -692,10 +688,7 @@ mod test {
.expect("Expected to err out"); .expect("Expected to err out");
let my_keypair = Arc::new(my_keypair); let my_keypair = Arc::new(my_keypair);
let vote_signer = Arc::new(VoteSignerProxy::new( let vote_signer = Arc::new(VoteSignerProxy::new_local(&my_keypair));
&my_keypair,
Box::new(LocalVoteSigner::default()),
));
let res = ReplayStage::process_entries( let res = ReplayStage::process_entries(
&Arc::new(Bank::default()), &Arc::new(Bank::default()),
&cluster_info_me, &cluster_info_me,

View File

@ -452,7 +452,6 @@ mod tests {
use solana_sdk::system_instruction::SystemInstruction; use solana_sdk::system_instruction::SystemInstruction;
use solana_sdk::vote_program::VoteProgram; use solana_sdk::vote_program::VoteProgram;
use solana_sdk::vote_transaction::VoteTransaction; use solana_sdk::vote_transaction::VoteTransaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
#[test] #[test]
@ -473,8 +472,7 @@ mod tests {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,
@ -527,8 +525,7 @@ mod tests {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,
@ -587,8 +584,7 @@ mod tests {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let entry_height = 0; let entry_height = 0;
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
@ -633,10 +629,7 @@ mod tests {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let leader_vote_account_keypair = Arc::new(Keypair::new()); let leader_vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = VoteSignerProxy::new( let vote_signer = VoteSignerProxy::new_local(&leader_vote_account_keypair);
&leader_vote_account_keypair,
Box::new(LocalVoteSigner::default()),
);
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,
Some(Arc::new(vote_signer)), Some(Arc::new(vote_signer)),
@ -729,8 +722,7 @@ mod tests {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let entry_height = 0; let entry_height = 0;
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(

View File

@ -199,7 +199,6 @@ pub mod tests {
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction; use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
use std::net::UdpSocket; use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@ -280,8 +279,7 @@ pub mod tests {
let db_ledger = let db_ledger =
DbLedger::open(&db_ledger_path).expect("Expected to successfully open ledger"); DbLedger::open(&db_ledger_path).expect("Expected to successfully open ledger");
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let (sender, _) = channel(); let (sender, _) = channel();
let tvu = Tvu::new( let tvu = Tvu::new(
Some(Arc::new(vote_signer)), Some(Arc::new(vote_signer)),

View File

@ -16,6 +16,7 @@ use solana_sdk::signature::{Keypair, KeypairUtil, Signature};
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program::Vote; use solana_sdk::vote_program::Vote;
use solana_sdk::vote_transaction::VoteTransaction; use solana_sdk::vote_transaction::VoteTransaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use solana_vote_signer::rpc::VoteSigner; use solana_vote_signer::rpc::VoteSigner;
use std::net::SocketAddr; use std::net::SocketAddr;
use std::sync::atomic::AtomicUsize; use std::sync::atomic::AtomicUsize;
@ -98,6 +99,10 @@ impl VoteSignerProxy {
} }
} }
pub fn new_local(keypair: &Arc<Keypair>) -> Self {
Self::new(keypair, Box::new(LocalVoteSigner::default()))
}
pub fn new_vote_account(&self, bank: &Bank, num_tokens: u64, last_id: Hash) -> Result<()> { pub fn new_vote_account(&self, bank: &Bank, num_tokens: u64, last_id: Hash) -> Result<()> {
// Create and register the new vote account // Create and register the new vote account
let tx = let tx =
@ -209,7 +214,6 @@ mod test {
use crate::genesis_block::GenesisBlock; use crate::genesis_block::GenesisBlock;
use crate::vote_signer_proxy::VoteSignerProxy; use crate::vote_signer_proxy::VoteSignerProxy;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::time::Duration; use std::time::Duration;
@ -218,10 +222,7 @@ mod test {
pub fn test_pending_votes() { pub fn test_pending_votes() {
solana_logger::setup(); solana_logger::setup();
let signer = VoteSignerProxy::new( let signer = VoteSignerProxy::new_local(&Arc::new(Keypair::new()));
&Arc::new(Keypair::new()),
Box::new(LocalVoteSigner::default()),
);
// Set up dummy node to host a ReplayStage // Set up dummy node to host a ReplayStage
let my_keypair = Keypair::new(); let my_keypair = Keypair::new();

View File

@ -24,7 +24,6 @@ use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction; use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::timing::duration_as_s; use solana_sdk::timing::duration_as_s;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use std::collections::{HashSet, VecDeque}; use std::collections::{HashSet, VecDeque};
use std::env; use std::env;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
@ -154,7 +153,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
.unwrap(); .unwrap();
} }
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let leader = Fullnode::new( let leader = Fullnode::new(
leader, leader,
&leader_ledger_path, &leader_ledger_path,
@ -174,7 +173,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
let validator_pubkey = keypair.pubkey().clone(); let validator_pubkey = keypair.pubkey().clone();
let validator = Node::new_localhost_with_pubkey(keypair.pubkey()); let validator = Node::new_localhost_with_pubkey(keypair.pubkey());
let validator_data = validator.info.clone(); let validator_data = validator.info.clone();
let signer_proxy = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&keypair);
let validator = Fullnode::new( let validator = Fullnode::new(
validator, validator,
&zero_ledger_path, &zero_ledger_path,
@ -258,7 +257,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
"multi_node_validator_catchup_from_zero", "multi_node_validator_catchup_from_zero",
); );
ledger_paths.push(leader_ledger_path.clone()); ledger_paths.push(leader_ledger_path.clone());
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let server = Fullnode::new( let server = Fullnode::new(
leader, leader,
&leader_ledger_path, &leader_ledger_path,
@ -292,7 +291,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
validator_pubkey, validator_balance validator_pubkey, validator_balance
); );
let signer_proxy = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&keypair);
let val = Fullnode::new( let val = Fullnode::new(
validator, validator,
&ledger_path, &ledger_path,
@ -353,7 +352,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
let keypair = Arc::new(Keypair::new()); let keypair = Arc::new(Keypair::new());
let validator_pubkey = keypair.pubkey().clone(); let validator_pubkey = keypair.pubkey().clone();
let validator = Node::new_localhost_with_pubkey(keypair.pubkey()); let validator = Node::new_localhost_with_pubkey(keypair.pubkey());
let signer_proxy = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&keypair);
info!("created start from zero validator {:?}", validator_pubkey); info!("created start from zero validator {:?}", validator_pubkey);
let val = Fullnode::new( let val = Fullnode::new(
@ -445,7 +444,7 @@ fn test_multi_node_basic() {
let leader_ledger_path = tmp_copy_ledger(&genesis_ledger_path, "multi_node_basic"); let leader_ledger_path = tmp_copy_ledger(&genesis_ledger_path, "multi_node_basic");
ledger_paths.push(leader_ledger_path.clone()); ledger_paths.push(leader_ledger_path.clone());
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let server = Fullnode::new( let server = Fullnode::new(
leader, leader,
&leader_ledger_path, &leader_ledger_path,
@ -475,7 +474,7 @@ fn test_multi_node_basic() {
"validator {}, balance {}", "validator {}, balance {}",
validator_pubkey, validator_balance validator_pubkey, validator_balance
); );
let signer_proxy = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&keypair);
let val = Fullnode::new( let val = Fullnode::new(
validator, validator,
&ledger_path, &ledger_path,
@ -555,7 +554,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
ledger_paths.push(leader_ledger_path.clone()); ledger_paths.push(leader_ledger_path.clone());
let leader_data = leader.info.clone(); let leader_data = leader.info.clone();
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let leader_fullnode = Fullnode::new( let leader_fullnode = Fullnode::new(
leader, leader,
&leader_ledger_path, &leader_ledger_path,
@ -580,7 +579,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
let validator_data = validator.info.clone(); let validator_data = validator.info.clone();
let ledger_path = tmp_copy_ledger(&genesis_ledger_path, "boot_validator_from_file"); let ledger_path = tmp_copy_ledger(&genesis_ledger_path, "boot_validator_from_file");
ledger_paths.push(ledger_path.clone()); ledger_paths.push(ledger_path.clone());
let signer_proxy = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&keypair);
let val_fullnode = Fullnode::new( let val_fullnode = Fullnode::new(
validator, validator,
&ledger_path, &ledger_path,
@ -646,10 +645,7 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
); );
let bob_pubkey = Keypair::new().pubkey(); let bob_pubkey = Keypair::new().pubkey();
let signer_proxy = Arc::new(VoteSignerProxy::new( let signer_proxy = Arc::new(VoteSignerProxy::new_local(&leader_keypair));
&leader_keypair,
Box::new(LocalVoteSigner::default()),
));
{ {
let (leader_data, leader_fullnode) = let (leader_data, leader_fullnode) =
@ -693,7 +689,7 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
let validator = Node::new_localhost_with_pubkey(keypair.pubkey()); let validator = Node::new_localhost_with_pubkey(keypair.pubkey());
let validator_data = validator.info.clone(); let validator_data = validator.info.clone();
let signer_proxy = VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&keypair);
let val_fullnode = Fullnode::new( let val_fullnode = Fullnode::new(
validator, validator,
&stale_ledger_path, &stale_ledger_path,
@ -762,7 +758,7 @@ fn test_multi_node_dynamic_network() {
let leader_ledger_path = tmp_copy_ledger(&genesis_ledger_path, "multi_node_dynamic_network"); let leader_ledger_path = tmp_copy_ledger(&genesis_ledger_path, "multi_node_dynamic_network");
ledger_paths.push(leader_ledger_path.clone()); ledger_paths.push(leader_ledger_path.clone());
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let server = Fullnode::new( let server = Fullnode::new(
leader, leader,
&leader_ledger_path, &leader_ledger_path,
@ -834,8 +830,7 @@ fn test_multi_node_dynamic_network() {
let rd = validator.info.clone(); let rd = validator.info.clone();
info!("starting {} {}", keypair.pubkey(), rd.id); info!("starting {} {}", keypair.pubkey(), rd.id);
let keypair = Arc::new(keypair); let keypair = Arc::new(keypair);
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&keypair);
VoteSignerProxy::new(&keypair, Box::new(LocalVoteSigner::default()));
let val = Fullnode::new( let val = Fullnode::new(
validator, validator,
&ledger_path, &ledger_path,
@ -1018,7 +1013,7 @@ fn test_leader_to_validator_transition() {
Some(bootstrap_height), Some(bootstrap_height),
); );
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let mut leader = Fullnode::new( let mut leader = Fullnode::new(
leader_node, leader_node,
&leader_ledger_path, &leader_ledger_path,
@ -1173,8 +1168,7 @@ fn test_leader_validator_basic() {
); );
// Start the validator node // Start the validator node
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&validator_keypair);
VoteSignerProxy::new(&validator_keypair, Box::new(LocalVoteSigner::default()));
let mut validator = Fullnode::new( let mut validator = Fullnode::new(
validator_node, validator_node,
&validator_ledger_path, &validator_ledger_path,
@ -1187,7 +1181,7 @@ fn test_leader_validator_basic() {
); );
// Start the leader fullnode // Start the leader fullnode
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let mut leader = Fullnode::new( let mut leader = Fullnode::new(
leader_node, leader_node,
&leader_ledger_path, &leader_ledger_path,
@ -1378,10 +1372,7 @@ fn test_dropped_handoff_recovery() {
info!("bootstrap_leader: {}", bootstrap_leader_keypair.pubkey()); info!("bootstrap_leader: {}", bootstrap_leader_keypair.pubkey());
info!("'next leader': {}", next_leader_keypair.pubkey()); info!("'next leader': {}", next_leader_keypair.pubkey());
let signer_proxy = VoteSignerProxy::new( let signer_proxy = VoteSignerProxy::new_local(&bootstrap_leader_keypair);
&bootstrap_leader_keypair,
Box::new(LocalVoteSigner::default()),
);
// Start up the bootstrap leader fullnode // Start up the bootstrap leader fullnode
let bootstrap_leader_ledger_path = let bootstrap_leader_ledger_path =
tmp_copy_ledger(&genesis_ledger_path, "test_dropped_handoff_recovery"); tmp_copy_ledger(&genesis_ledger_path, "test_dropped_handoff_recovery");
@ -1408,7 +1399,7 @@ fn test_dropped_handoff_recovery() {
let validator_id = kp.pubkey(); let validator_id = kp.pubkey();
info!("validator {}: {}", i, validator_id); info!("validator {}: {}", i, validator_id);
let validator_node = Node::new_localhost_with_pubkey(validator_id); let validator_node = Node::new_localhost_with_pubkey(validator_id);
let signer_proxy = VoteSignerProxy::new(&kp, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&kp);
let validator = Fullnode::new( let validator = Fullnode::new(
validator_node, validator_node,
&validator_ledger_path, &validator_ledger_path,
@ -1435,8 +1426,7 @@ fn test_dropped_handoff_recovery() {
info!("Starting the 'next leader' node"); info!("Starting the 'next leader' node");
let next_leader_node = Node::new_localhost_with_pubkey(next_leader_keypair.pubkey()); let next_leader_node = Node::new_localhost_with_pubkey(next_leader_keypair.pubkey());
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&next_leader_keypair);
VoteSignerProxy::new(&next_leader_keypair, Box::new(LocalVoteSigner::default()));
let next_leader = Fullnode::new( let next_leader = Fullnode::new(
next_leader_node, next_leader_node,
&next_leader_ledger_path, &next_leader_ledger_path,
@ -1584,7 +1574,7 @@ fn test_full_leader_validator_network() {
let validator_id = kp.pubkey(); let validator_id = kp.pubkey();
let validator_node = Node::new_localhost_with_pubkey(validator_id); let validator_node = Node::new_localhost_with_pubkey(validator_id);
let signer_proxy = VoteSignerProxy::new(&kp, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&kp);
let leader_scheduler = let leader_scheduler =
Arc::new(RwLock::new(LeaderScheduler::new(&leader_scheduler_config))); Arc::new(RwLock::new(LeaderScheduler::new(&leader_scheduler_config)));
let validator = Fullnode::new( let validator = Fullnode::new(
@ -1603,7 +1593,7 @@ fn test_full_leader_validator_network() {
} }
info!("Start up the bootstrap leader"); info!("Start up the bootstrap leader");
let signer_proxy = VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default())); let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
let leader_scheduler = Arc::new(RwLock::new(LeaderScheduler::new(&leader_scheduler_config))); let leader_scheduler = Arc::new(RwLock::new(LeaderScheduler::new(&leader_scheduler_config)));
let bootstrap_leader = Fullnode::new( let bootstrap_leader = Fullnode::new(
bootstrap_leader_node, bootstrap_leader_node,
@ -1782,10 +1772,7 @@ fn test_broadcast_last_tick() {
// Start up the bootstrap leader fullnode // Start up the bootstrap leader fullnode
let bootstrap_leader_keypair = Arc::new(bootstrap_leader_keypair); let bootstrap_leader_keypair = Arc::new(bootstrap_leader_keypair);
let signer_proxy = VoteSignerProxy::new( let signer_proxy = VoteSignerProxy::new_local(&bootstrap_leader_keypair);
&bootstrap_leader_keypair,
Box::new(LocalVoteSigner::default()),
);
let mut bootstrap_leader = Fullnode::new( let mut bootstrap_leader = Fullnode::new(
bootstrap_leader_node, bootstrap_leader_node,
&bootstrap_leader_ledger_path, &bootstrap_leader_ledger_path,

View File

@ -21,7 +21,6 @@ use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction; use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
@ -48,8 +47,7 @@ fn test_replicator_startup() {
tmp_copy_ledger(&leader_ledger_path, "replicator_test_validator_ledger"); tmp_copy_ledger(&leader_ledger_path, "replicator_test_validator_ledger");
{ {
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default()));
let leader = Fullnode::new_with_storage_rotate( let leader = Fullnode::new_with_storage_rotate(
leader_node, leader_node,
@ -66,8 +64,7 @@ fn test_replicator_startup() {
); );
let validator_keypair = Arc::new(Keypair::new()); let validator_keypair = Arc::new(Keypair::new());
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&validator_keypair);
VoteSignerProxy::new(&validator_keypair, Box::new(LocalVoteSigner::default()));
let mut leader_client = mk_client(&leader_info); let mut leader_client = mk_client(&leader_info);
@ -277,8 +274,7 @@ fn test_replicator_startup_ledger_hang() {
tmp_copy_ledger(&leader_ledger_path, "replicator_test_validator_ledger"); tmp_copy_ledger(&leader_ledger_path, "replicator_test_validator_ledger");
{ {
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&leader_keypair);
VoteSignerProxy::new(&leader_keypair, Box::new(LocalVoteSigner::default()));
let _ = Fullnode::new( let _ = Fullnode::new(
leader_node, leader_node,
@ -294,8 +290,7 @@ fn test_replicator_startup_ledger_hang() {
); );
let validator_keypair = Arc::new(Keypair::new()); let validator_keypair = Arc::new(Keypair::new());
let signer_proxy = let signer_proxy = VoteSignerProxy::new_local(&validator_keypair);
VoteSignerProxy::new(&validator_keypair, Box::new(LocalVoteSigner::default()));
let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey()); let validator_node = Node::new_localhost_with_pubkey(validator_keypair.pubkey());
let _ = Fullnode::new( let _ = Fullnode::new(

View File

@ -14,7 +14,6 @@ use solana::vote_signer_proxy::VoteSignerProxy;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction; use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction; use solana_sdk::transaction::Transaction;
use solana_vote_signer::rpc::LocalVoteSigner;
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
use std::thread::sleep; use std::thread::sleep;
@ -42,8 +41,7 @@ fn test_rpc_send_tx() {
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let entry_height = 0; let entry_height = 0;
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,

View File

@ -11,7 +11,6 @@ use solana::vote_signer_proxy::VoteSignerProxy;
use solana_drone::drone::run_local_drone; use solana_drone::drone::run_local_drone;
use solana_sdk::bpf_loader; use solana_sdk::bpf_loader;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig}; use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig};
use std::fs::{remove_dir_all, File}; use std::fs::{remove_dir_all, File};
use std::io::Read; use std::io::Read;
@ -41,8 +40,7 @@ fn test_wallet_deploy_program() {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,

View File

@ -12,7 +12,6 @@ use solana::vote_signer_proxy::VoteSignerProxy;
use solana_drone::drone::run_local_drone; use solana_drone::drone::run_local_drone;
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use solana_wallet::wallet::{ use solana_wallet::wallet::{
process_command, request_and_confirm_airdrop, WalletCommand, WalletConfig, process_command, request_and_confirm_airdrop, WalletCommand, WalletConfig,
}; };
@ -46,8 +45,7 @@ fn test_wallet_timestamp_tx() {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,
@ -142,8 +140,7 @@ fn test_wallet_witness_tx() {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,
@ -234,8 +231,7 @@ fn test_wallet_cancel_tx() {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,

View File

@ -10,7 +10,6 @@ use solana::storage_stage::STORAGE_ROTATE_TEST_COUNT;
use solana::vote_signer_proxy::VoteSignerProxy; use solana::vote_signer_proxy::VoteSignerProxy;
use solana_drone::drone::run_local_drone; use solana_drone::drone::run_local_drone;
use solana_sdk::signature::{Keypair, KeypairUtil}; use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_vote_signer::rpc::LocalVoteSigner;
use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig}; use solana_wallet::wallet::{process_command, WalletCommand, WalletConfig};
use std::fs::remove_dir_all; use std::fs::remove_dir_all;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
@ -32,8 +31,7 @@ fn test_wallet_request_airdrop() {
))); )));
bank.leader_scheduler = leader_scheduler; bank.leader_scheduler = leader_scheduler;
let vote_account_keypair = Arc::new(Keypair::new()); let vote_account_keypair = Arc::new(Keypair::new());
let vote_signer = let vote_signer = VoteSignerProxy::new_local(&vote_account_keypair);
VoteSignerProxy::new(&vote_account_keypair, Box::new(LocalVoteSigner::default()));
let last_id = bank.last_id(); let last_id = bank.last_id();
let server = Fullnode::new_with_bank( let server = Fullnode::new_with_bank(
leader_keypair, leader_keypair,