Disable Rpc module for other tests to prevent port conflicts
This commit is contained in:
parent
c6662a4512
commit
1eb8724a89
|
@ -83,11 +83,11 @@ fn main() -> () {
|
|||
let testnet_addr: SocketAddr = testnet_address_string.parse().unwrap();
|
||||
drone_addr.set_ip(testnet_addr.ip());
|
||||
|
||||
Fullnode::new(node, false, ledger_path, keypair, Some(testnet_addr))
|
||||
Fullnode::new(node, false, ledger_path, keypair, Some(testnet_addr), true)
|
||||
} else {
|
||||
node.data.leader_id = node.data.id;
|
||||
|
||||
Fullnode::new(node, true, ledger_path, keypair, None)
|
||||
Fullnode::new(node, true, ledger_path, keypair, None, true)
|
||||
};
|
||||
|
||||
let mut client = mk_client(&repl_clone);
|
||||
|
|
|
@ -294,6 +294,7 @@ mod tests {
|
|||
exit.clone(),
|
||||
&ledger_path,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
//TODO: this seems unstable
|
||||
sleep(Duration::from_millis(900));
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -372,6 +372,7 @@ mod tests {
|
|||
exit.clone(),
|
||||
&ledger_path,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
sleep(Duration::from_millis(900));
|
||||
|
||||
|
@ -419,6 +420,7 @@ mod tests {
|
|||
exit.clone(),
|
||||
&ledger_path,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
//TODO: remove this sleep, or add a retry so CI is stable
|
||||
sleep(Duration::from_millis(300));
|
||||
|
@ -478,6 +480,7 @@ mod tests {
|
|||
exit.clone(),
|
||||
&ledger_path,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
sleep(Duration::from_millis(300));
|
||||
|
||||
|
|
|
@ -145,7 +145,14 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
|
|||
writer.write_entries(entries).unwrap();
|
||||
}
|
||||
|
||||
let leader = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let leader = Fullnode::new(
|
||||
leader,
|
||||
true,
|
||||
&leader_ledger_path,
|
||||
leader_keypair,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -163,6 +170,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
|
|||
&zero_ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
|
||||
// contains the leader and new node
|
||||
|
@ -218,7 +226,14 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
);
|
||||
ledger_paths.push(zero_ledger_path.clone());
|
||||
|
||||
let server = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(
|
||||
leader,
|
||||
true,
|
||||
&leader_ledger_path,
|
||||
leader_keypair,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -241,6 +256,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
nodes.push(val);
|
||||
}
|
||||
|
@ -276,6 +292,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
&zero_ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
nodes.push(val);
|
||||
//contains the leader and new node
|
||||
|
@ -335,7 +352,14 @@ fn test_multi_node_basic() {
|
|||
|
||||
let (alice, leader_ledger_path) = genesis("multi_node_basic", 10_000);
|
||||
ledger_paths.push(leader_ledger_path.clone());
|
||||
let server = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(
|
||||
leader,
|
||||
true,
|
||||
&leader_ledger_path,
|
||||
leader_keypair,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -354,6 +378,7 @@ fn test_multi_node_basic() {
|
|||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
nodes.push(val);
|
||||
}
|
||||
|
@ -396,7 +421,14 @@ fn test_boot_validator_from_file() -> result::Result<()> {
|
|||
ledger_paths.push(leader_ledger_path.clone());
|
||||
|
||||
let leader_data = leader.data.clone();
|
||||
let leader_fullnode = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let leader_fullnode = Fullnode::new(
|
||||
leader,
|
||||
true,
|
||||
&leader_ledger_path,
|
||||
leader_keypair,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
let leader_balance =
|
||||
send_tx_and_retry_get_balance(&leader_data, &alice, &bob_pubkey, Some(500)).unwrap();
|
||||
assert_eq!(leader_balance, 500);
|
||||
|
@ -415,6 +447,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
|
|||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
let mut client = mk_client(&validator_data);
|
||||
let getbal = retry_get_balance(&mut client, &bob_pubkey, Some(leader_balance));
|
||||
|
@ -433,7 +466,7 @@ fn create_leader(ledger_path: &str) -> (NodeInfo, Fullnode) {
|
|||
let leader_keypair = Keypair::new();
|
||||
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let leader_data = leader.data.clone();
|
||||
let leader_fullnode = Fullnode::new(leader, true, &ledger_path, leader_keypair, None);
|
||||
let leader_fullnode = Fullnode::new(leader, true, &ledger_path, leader_keypair, None, false);
|
||||
(leader_data, leader_fullnode)
|
||||
}
|
||||
|
||||
|
@ -484,6 +517,7 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
|
|||
&stale_ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
|
||||
// trigger broadcast, validator should catch up from leader, whose window contains
|
||||
|
@ -538,8 +572,14 @@ fn test_multi_node_dynamic_network() {
|
|||
let alice_arc = Arc::new(RwLock::new(alice));
|
||||
let leader_data = leader.data.clone();
|
||||
|
||||
let server =
|
||||
Fullnode::new_without_sigverify(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new_without_sigverify(
|
||||
leader,
|
||||
true,
|
||||
&leader_ledger_path,
|
||||
leader_keypair,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance = send_tx_and_retry_get_balance(
|
||||
|
@ -613,6 +653,7 @@ fn test_multi_node_dynamic_network() {
|
|||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
(rd, val)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue