Less constructors
This commit is contained in:
parent
57daeb35d2
commit
be58fdf1bb
|
@ -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, ledger_path, keypair, Some(testnet_addr))
|
||||
Fullnode::new(node, ledger_path, keypair, Some(testnet_addr), false)
|
||||
} else {
|
||||
node.data.leader_id = node.data.id;
|
||||
|
||||
Fullnode::new(node, ledger_path, keypair, None)
|
||||
Fullnode::new(node, ledger_path, keypair, None, false)
|
||||
};
|
||||
|
||||
let mut client = mk_client(&repl_clone);
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Config {
|
|||
}
|
||||
|
||||
impl Fullnode {
|
||||
fn new_internal(
|
||||
pub fn new(
|
||||
node: TestNode,
|
||||
ledger_path: &str,
|
||||
keypair: Keypair,
|
||||
|
@ -154,30 +154,6 @@ impl Fullnode {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
node: TestNode,
|
||||
ledger: &str,
|
||||
keypair: Keypair,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
) -> Self {
|
||||
Self::new_internal(node, ledger, keypair, network_entry_for_validator, false)
|
||||
}
|
||||
|
||||
pub fn new_without_sigverify(
|
||||
node: TestNode,
|
||||
ledger_path: &str,
|
||||
keypair: Keypair,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
) -> Self {
|
||||
Self::new_internal(
|
||||
node,
|
||||
ledger_path,
|
||||
keypair,
|
||||
network_entry_for_validator,
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
/// Create a server instance acting as a leader.
|
||||
///
|
||||
/// ```text
|
||||
|
|
|
@ -145,7 +145,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
|
|||
writer.write_entries(entries).unwrap();
|
||||
}
|
||||
|
||||
let leader = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None);
|
||||
let leader = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None, false);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -162,6 +162,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
|
||||
|
@ -217,7 +218,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
);
|
||||
ledger_paths.push(zero_ledger_path.clone());
|
||||
|
||||
let server = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None, false);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -239,6 +240,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
nodes.push(val);
|
||||
}
|
||||
|
@ -273,6 +275,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
|
||||
|
@ -332,7 +335,7 @@ 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, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None, false);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -350,6 +353,7 @@ fn test_multi_node_basic() {
|
|||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
false,
|
||||
);
|
||||
nodes.push(val);
|
||||
}
|
||||
|
@ -392,7 +396,7 @@ 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, &leader_ledger_path, leader_keypair, None);
|
||||
let leader_fullnode = Fullnode::new(leader, &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);
|
||||
|
@ -410,6 +414,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));
|
||||
|
@ -428,7 +433,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, &ledger_path, leader_keypair, None);
|
||||
let leader_fullnode = Fullnode::new(leader, &ledger_path, leader_keypair, None, false);
|
||||
(leader_data, leader_fullnode)
|
||||
}
|
||||
|
||||
|
@ -478,6 +483,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
|
||||
|
@ -532,7 +538,7 @@ 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, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None, true);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance = send_tx_and_retry_get_balance(
|
||||
|
@ -600,11 +606,12 @@ fn test_multi_node_dynamic_network() {
|
|||
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
|
||||
let rd = validator.data.clone();
|
||||
info!("starting {} {:x}", keypair.pubkey(), rd.debug_id());
|
||||
let val = Fullnode::new_without_sigverify(
|
||||
let val = Fullnode::new(
|
||||
validator,
|
||||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
true,
|
||||
);
|
||||
(rd, val)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue