Disable Rpc module for other tests to prevent port conflicts

This commit is contained in:
Tyera Eulberg
2018-08-14 18:37:30 -06:00
committed by Tyera Eulberg
parent c6662a4512
commit 1eb8724a89
5 changed files with 80 additions and 19 deletions

View File

@ -55,6 +55,7 @@ impl Fullnode {
keypair: Keypair,
network_entry_for_validator: Option<SocketAddr>,
sigverify_disabled: bool,
json_rpc_enabled: bool,
) -> Self {
info!("creating bank...");
let bank = Bank::new_default(leader);
@ -93,6 +94,7 @@ impl Fullnode {
exit.clone(),
Some(ledger_path),
sigverify_disabled,
json_rpc_enabled,
);
info!(
"validator ready... local request address: {} (advertising {}) connected to: {}",
@ -111,6 +113,7 @@ impl Fullnode {
exit.clone(),
ledger_path,
sigverify_disabled,
json_rpc_enabled,
);
info!(
"leader ready... local request address: {} (advertising {})",
@ -126,6 +129,7 @@ impl Fullnode {
ledger: &str,
keypair: Keypair,
network_entry_for_validator: Option<SocketAddr>,
json_rpc_enabled: bool,
) -> Self {
Self::new_internal(
node,
@ -134,6 +138,7 @@ impl Fullnode {
keypair,
network_entry_for_validator,
false,
json_rpc_enabled,
)
}
@ -143,6 +148,7 @@ impl Fullnode {
ledger_path: &str,
keypair: Keypair,
network_entry_for_validator: Option<SocketAddr>,
json_rpc_enabled: bool,
) -> Self {
Self::new_internal(
node,
@ -151,6 +157,7 @@ impl Fullnode {
keypair,
network_entry_for_validator,
true,
json_rpc_enabled,
)
}
@ -178,6 +185,7 @@ impl Fullnode {
/// | | `------------`
/// `---------------------`
/// ```
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new_leader(
keypair: Keypair,
bank: Bank,
@ -187,6 +195,7 @@ impl Fullnode {
exit: Arc<AtomicBool>,
ledger_path: &str,
sigverify_disabled: bool,
json_rpc_enabled: bool,
) -> Self {
let tick_duration = None;
// TODO: To light up PoH, uncomment the following line:
@ -202,10 +211,12 @@ impl Fullnode {
);
thread_hdls.extend(rpu.thread_hdls());
let mut rpc_addr = node.data.contact_info.ncp;
rpc_addr.set_port(RPC_PORT);
let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr);
thread_hdls.extend(rpc_service.thread_hdls());
if json_rpc_enabled {
let mut rpc_addr = node.data.contact_info.ncp;
rpc_addr.set_port(RPC_PORT);
let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr);
thread_hdls.extend(rpc_service.thread_hdls());
}
let blob_recycler = BlobRecycler::default();
let window =
@ -277,6 +288,7 @@ impl Fullnode {
/// `--------` | | `------------`
/// `-------------------------------`
/// ```
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn new_validator(
keypair: Keypair,
bank: Bank,
@ -287,6 +299,7 @@ impl Fullnode {
exit: Arc<AtomicBool>,
ledger_path: Option<&str>,
_sigverify_disabled: bool,
json_rpc_enabled: bool,
) -> Self {
let bank = Arc::new(bank);
let mut thread_hdls = vec![];
@ -298,10 +311,12 @@ impl Fullnode {
);
thread_hdls.extend(rpu.thread_hdls());
let mut rpc_addr = node.data.contact_info.ncp;
rpc_addr.set_port(RPC_PORT);
let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr);
thread_hdls.extend(rpc_service.thread_hdls());
if json_rpc_enabled {
let mut rpc_addr = node.data.contact_info.ncp;
rpc_addr.set_port(RPC_PORT);
let rpc_service = JsonRpcService::new(bank.clone(), rpc_addr);
thread_hdls.extend(rpc_service.thread_hdls());
}
let blob_recycler = BlobRecycler::default();
let window =
@ -380,7 +395,8 @@ mod tests {
let bank = Bank::new(&alice);
let exit = Arc::new(AtomicBool::new(false));
let entry = tn.data.clone();
let v = Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false);
let v =
Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false, false);
v.exit();
v.join().unwrap();
}
@ -394,7 +410,7 @@ mod tests {
let bank = Bank::new(&alice);
let exit = Arc::new(AtomicBool::new(false));
let entry = tn.data.clone();
Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false)
Fullnode::new_validator(keypair, bank, 0, &[], tn, &entry, exit, None, false, false)
})
.collect();
//each validator can exit in parallel to speed many sequential calls to `join`