groom Fullnode's new_with_bank() to match new() more
This commit is contained in:
parent
a8fdb8a5a7
commit
b52230097e
|
@ -163,12 +163,9 @@ mod tests {
|
|||
use logger;
|
||||
use mint::Mint;
|
||||
use netutil::get_ip_addr;
|
||||
use service::Service;
|
||||
use signature::{Keypair, KeypairUtil};
|
||||
use std::fs::remove_dir_all;
|
||||
use std::net::{SocketAddr, UdpSocket};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use thin_client::ThinClient;
|
||||
|
||||
|
@ -262,7 +259,6 @@ mod tests {
|
|||
let bank = Bank::new(&alice);
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let carlos_pubkey = Keypair::new().pubkey();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = tmp_ledger_path("send_airdrop");
|
||||
|
||||
|
@ -273,7 +269,6 @@ mod tests {
|
|||
&[],
|
||||
leader,
|
||||
None,
|
||||
exit.clone(),
|
||||
Some(&ledger_path),
|
||||
false,
|
||||
);
|
||||
|
@ -307,8 +302,7 @@ mod tests {
|
|||
assert!(client.poll_for_signature(&bob_sig).is_ok());
|
||||
|
||||
// restart the leader, drone should find the new one at the same gossip port
|
||||
exit.store(true, Ordering::Relaxed);
|
||||
server.join().unwrap();
|
||||
server.close().unwrap();
|
||||
|
||||
let leader_keypair = Keypair::new();
|
||||
let leader = Node::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
|
|
|
@ -61,7 +61,8 @@ impl Fullnode {
|
|||
|
||||
let entries = read_ledger(ledger_path, true).expect("opening ledger");
|
||||
|
||||
let entries = entries.map(|e| e.expect("failed to parse entry"));
|
||||
let entries = entries
|
||||
.map(|e| e.unwrap_or_else(|err| panic!("failed to parse entry. error: {}", err)));
|
||||
|
||||
info!("processing ledger...");
|
||||
let (entry_height, ledger_tail) = bank.process_ledger(entries).expect("process_ledger");
|
||||
|
@ -76,7 +77,7 @@ impl Fullnode {
|
|||
"starting... local gossip address: {} (advertising {})",
|
||||
local_gossip_addr, node.info.contact_info.ncp
|
||||
);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
|
||||
let local_requests_addr = node.sockets.requests.local_addr().unwrap();
|
||||
let requests_addr = node.info.contact_info.rpu;
|
||||
let leader_info = leader_addr.map(|i| NodeInfo::new_entry_point(&i));
|
||||
|
@ -87,7 +88,6 @@ impl Fullnode {
|
|||
&ledger_tail,
|
||||
node,
|
||||
leader_info.as_ref(),
|
||||
exit,
|
||||
Some(ledger_path),
|
||||
sigverify_disabled,
|
||||
);
|
||||
|
@ -167,14 +167,13 @@ impl Fullnode {
|
|||
ledger_tail: &[Entry],
|
||||
mut node: Node,
|
||||
leader_info: Option<&NodeInfo>,
|
||||
exit: Arc<AtomicBool>,
|
||||
ledger_path: Option<&str>,
|
||||
sigverify_disabled: bool,
|
||||
) -> Self {
|
||||
if leader_info.is_none() {
|
||||
node.info.leader_id = node.info.id;
|
||||
}
|
||||
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let bank = Arc::new(bank);
|
||||
let blob_recycler = BlobRecycler::default();
|
||||
let mut thread_hdls = vec![];
|
||||
|
@ -303,8 +302,6 @@ mod tests {
|
|||
use mint::Mint;
|
||||
use service::Service;
|
||||
use signature::{Keypair, KeypairUtil};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[test]
|
||||
fn validator_exit() {
|
||||
|
@ -312,11 +309,9 @@ mod tests {
|
|||
let tn = Node::new_localhost_with_pubkey(keypair.pubkey());
|
||||
let alice = Mint::new(10_000);
|
||||
let bank = Bank::new(&alice);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let entry = tn.info.clone();
|
||||
let v = Fullnode::new_with_bank(keypair, bank, 0, &[], tn, Some(&entry), exit, None, false);
|
||||
v.exit();
|
||||
v.join().unwrap();
|
||||
let v = Fullnode::new_with_bank(keypair, bank, 0, &[], tn, Some(&entry), None, false);
|
||||
v.close().unwrap();
|
||||
}
|
||||
#[test]
|
||||
fn validator_parallel_exit() {
|
||||
|
@ -326,9 +321,8 @@ mod tests {
|
|||
let tn = Node::new_localhost_with_pubkey(keypair.pubkey());
|
||||
let alice = Mint::new(10_000);
|
||||
let bank = Bank::new(&alice);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let entry = tn.info.clone();
|
||||
Fullnode::new_with_bank(keypair, bank, 0, &[], tn, Some(&entry), exit, None, false)
|
||||
Fullnode::new_with_bank(keypair, bank, 0, &[], tn, Some(&entry), None, false)
|
||||
})
|
||||
.collect();
|
||||
//each validator can exit in parallel to speed many sequential calls to `join`
|
||||
|
|
|
@ -438,11 +438,8 @@ mod tests {
|
|||
use ledger::LedgerWriter;
|
||||
use logger;
|
||||
use mint::Mint;
|
||||
use service::Service;
|
||||
use signature::{Keypair, KeypairUtil};
|
||||
use std::fs::remove_dir_all;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::Arc;
|
||||
use transaction::{Instruction, Plan};
|
||||
|
||||
fn tmp_ledger(name: &str, mint: &Mint) -> String {
|
||||
|
@ -468,7 +465,6 @@ mod tests {
|
|||
let alice = Mint::new(10_000);
|
||||
let bank = Bank::new(&alice);
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let ledger_path = tmp_ledger("thin_client", &alice);
|
||||
|
||||
let server = Fullnode::new_with_bank(
|
||||
|
@ -478,7 +474,6 @@ mod tests {
|
|||
&[],
|
||||
leader,
|
||||
None,
|
||||
exit.clone(),
|
||||
Some(&ledger_path),
|
||||
false,
|
||||
);
|
||||
|
@ -500,8 +495,7 @@ mod tests {
|
|||
client.poll_for_signature(&signature).unwrap();
|
||||
let balance = client.get_balance(&bob_pubkey);
|
||||
assert_eq!(balance.unwrap(), 500);
|
||||
exit.store(true, Ordering::Relaxed);
|
||||
server.join().unwrap();
|
||||
server.close().unwrap();
|
||||
remove_dir_all(ledger_path).unwrap();
|
||||
}
|
||||
|
||||
|
@ -515,7 +509,6 @@ mod tests {
|
|||
let alice = Mint::new(10_000);
|
||||
let bank = Bank::new(&alice);
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = tmp_ledger("bad_sig", &alice);
|
||||
|
||||
|
@ -526,7 +519,6 @@ mod tests {
|
|||
&[],
|
||||
leader,
|
||||
None,
|
||||
exit.clone(),
|
||||
Some(&ledger_path),
|
||||
false,
|
||||
);
|
||||
|
@ -564,8 +556,7 @@ mod tests {
|
|||
|
||||
let balance = client.get_balance(&bob_pubkey);
|
||||
assert_eq!(balance.unwrap(), 500);
|
||||
exit.store(true, Ordering::Relaxed);
|
||||
server.join().unwrap();
|
||||
server.close().unwrap();
|
||||
remove_dir_all(ledger_path).unwrap();
|
||||
}
|
||||
|
||||
|
@ -577,7 +568,6 @@ mod tests {
|
|||
let alice = Mint::new(10_000);
|
||||
let bank = Bank::new(&alice);
|
||||
let bob_pubkey = Keypair::new().pubkey();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = tmp_ledger("client_check_signature", &alice);
|
||||
|
||||
|
@ -588,7 +578,6 @@ mod tests {
|
|||
&[],
|
||||
leader,
|
||||
None,
|
||||
exit.clone(),
|
||||
Some(&ledger_path),
|
||||
false,
|
||||
);
|
||||
|
@ -613,8 +602,7 @@ mod tests {
|
|||
|
||||
assert!(client.check_signature(&signature));
|
||||
|
||||
exit.store(true, Ordering::Relaxed);
|
||||
server.join().unwrap();
|
||||
server.close().unwrap();
|
||||
remove_dir_all(ledger_path).unwrap();
|
||||
}
|
||||
|
||||
|
@ -640,7 +628,6 @@ mod tests {
|
|||
let alice = Mint::new(10_000);
|
||||
let bank = Bank::new(&alice);
|
||||
let bob_keypair = Keypair::new();
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
let leader_data = leader.info.clone();
|
||||
let ledger_path = tmp_ledger("zero_balance_check", &alice);
|
||||
|
||||
|
@ -651,7 +638,6 @@ mod tests {
|
|||
&[],
|
||||
leader,
|
||||
None,
|
||||
exit.clone(),
|
||||
Some(&ledger_path),
|
||||
false,
|
||||
);
|
||||
|
@ -690,8 +676,7 @@ mod tests {
|
|||
let balance = client.poll_get_balance(&bob_keypair.pubkey());
|
||||
assert!(balance.is_err());
|
||||
|
||||
exit.store(true, Ordering::Relaxed);
|
||||
server.join().unwrap();
|
||||
server.close().unwrap();
|
||||
remove_dir_all(ledger_path).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue