fixups
This commit is contained in:
parent
aaf6ce5aea
commit
710fa822a0
|
@ -7,7 +7,7 @@ extern crate solana;
|
|||
|
||||
use clap::{App, Arg};
|
||||
use solana::crdt::{NodeInfo, TestNode};
|
||||
use solana::fullnode::{Config, FullNode, Ledger};
|
||||
use solana::fullnode::{Config, FullNode, LedgerFile};
|
||||
use solana::service::Service;
|
||||
use solana::signature::{KeyPair, KeyPairUtil};
|
||||
use std::fs::File;
|
||||
|
@ -64,9 +64,9 @@ fn main() -> () {
|
|||
}
|
||||
}
|
||||
let ledger = if let Some(l) = matches.value_of("ledger") {
|
||||
Ledger::Path(l.to_string())
|
||||
LedgerFile::Path(l.to_string())
|
||||
} else {
|
||||
Ledger::StdInOut
|
||||
LedgerFile::StdInOut
|
||||
};
|
||||
|
||||
let mut node = TestNode::new_with_bind_addr(repl_data, bind_addr);
|
||||
|
|
|
@ -30,7 +30,7 @@ pub struct FullNode {
|
|||
thread_hdls: Vec<JoinHandle<()>>,
|
||||
}
|
||||
|
||||
pub enum Ledger {
|
||||
pub enum LedgerFile {
|
||||
StdInOut,
|
||||
Path(String),
|
||||
}
|
||||
|
@ -61,14 +61,14 @@ impl FullNode {
|
|||
pub fn new(
|
||||
mut node: TestNode,
|
||||
leader: bool,
|
||||
ledger: Ledger,
|
||||
ledger: LedgerFile,
|
||||
keypair_for_validator: Option<KeyPair>,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
) -> FullNode {
|
||||
info!("creating bank...");
|
||||
let bank = Bank::default();
|
||||
let (infile, outfile): (Box<Read>, Box<Write + Send>) = match ledger {
|
||||
Ledger::Path(path) => (
|
||||
LedgerFile::Path(path) => (
|
||||
Box::new(File::open(path.clone()).expect("opening ledger file")),
|
||||
Box::new(
|
||||
OpenOptions::new()
|
||||
|
@ -78,7 +78,7 @@ impl FullNode {
|
|||
.expect("opening ledger file"),
|
||||
),
|
||||
),
|
||||
Ledger::StdInOut => (Box::new(stdin()), Box::new(stdout())),
|
||||
LedgerFile::StdInOut => (Box::new(stdin()), Box::new(stdout())),
|
||||
};
|
||||
let reader = BufReader::new(infile);
|
||||
let entries = entry_writer::read_entries(reader).map(|e| e.expect("failed to parse entry"));
|
||||
|
|
|
@ -7,7 +7,7 @@ extern crate solana;
|
|||
use solana::crdt::TestNode;
|
||||
use solana::crdt::{Crdt, NodeInfo};
|
||||
use solana::entry_writer::EntryWriter;
|
||||
use solana::fullnode::{FullNode, Ledger};
|
||||
use solana::fullnode::{FullNode, LedgerFile};
|
||||
use solana::logger;
|
||||
use solana::mint::Mint;
|
||||
use solana::ncp::Ncp;
|
||||
|
@ -91,7 +91,13 @@ fn test_multi_node_validator_catchup_from_zero() {
|
|||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
|
||||
let (alice, ledger_path) = genesis(10_000);
|
||||
let server = FullNode::new(leader, true, Ledger::Path(ledger_path.clone()), None, None);
|
||||
let server = FullNode::new(
|
||||
leader,
|
||||
true,
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
let mut nodes = vec![server];
|
||||
for _ in 0..N {
|
||||
let keypair = KeyPair::new();
|
||||
|
@ -99,7 +105,7 @@ fn test_multi_node_validator_catchup_from_zero() {
|
|||
let mut val = FullNode::new(
|
||||
validator,
|
||||
false,
|
||||
Ledger::Path(ledger_path.clone()),
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
Some(keypair),
|
||||
Some(leader_data.contact_info.ncp),
|
||||
);
|
||||
|
@ -133,7 +139,7 @@ fn test_multi_node_validator_catchup_from_zero() {
|
|||
let val = FullNode::new(
|
||||
validator,
|
||||
false,
|
||||
Ledger::Path(ledger_path.clone()),
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
Some(keypair),
|
||||
Some(leader_data.contact_info.ncp),
|
||||
);
|
||||
|
@ -184,7 +190,13 @@ fn test_multi_node_basic() {
|
|||
let leader_data = leader.data.clone();
|
||||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
let (alice, ledger_path) = genesis(10_000);
|
||||
let server = FullNode::new(leader, true, Ledger::Path(ledger_path.clone()), None, None);
|
||||
let server = FullNode::new(
|
||||
leader,
|
||||
true,
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
let mut nodes = vec![server];
|
||||
for _ in 0..N {
|
||||
let keypair = KeyPair::new();
|
||||
|
@ -192,7 +204,7 @@ fn test_multi_node_basic() {
|
|||
let val = FullNode::new(
|
||||
validator,
|
||||
false,
|
||||
Ledger::Path(ledger_path.clone()),
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
Some(keypair),
|
||||
Some(leader_data.contact_info.ncp),
|
||||
);
|
||||
|
@ -231,8 +243,13 @@ fn test_boot_validator_from_file() {
|
|||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
let (alice, ledger_path) = genesis(100_000);
|
||||
let leader_data = leader.data.clone();
|
||||
let leader_fullnode =
|
||||
FullNode::new(leader, true, Ledger::Path(ledger_path.clone()), None, None);
|
||||
let leader_fullnode = FullNode::new(
|
||||
leader,
|
||||
true,
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
let leader_balance =
|
||||
send_tx_and_retry_get_balance(&leader_data, &alice, &bob_pubkey, Some(500)).unwrap();
|
||||
assert_eq!(leader_balance, 500);
|
||||
|
@ -246,7 +263,7 @@ fn test_boot_validator_from_file() {
|
|||
let val_fullnode = FullNode::new(
|
||||
validator,
|
||||
false,
|
||||
Ledger::Path(ledger_path.clone()),
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
Some(keypair),
|
||||
Some(leader_data.contact_info.ncp),
|
||||
);
|
||||
|
@ -265,7 +282,7 @@ fn create_leader(ledger_path: &str) -> (NodeInfo, FullNode) {
|
|||
let leader_fullnode = FullNode::new(
|
||||
leader,
|
||||
true,
|
||||
Ledger::Path(ledger_path.to_string()),
|
||||
LedgerFile::Path(ledger_path.to_string()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
@ -316,7 +333,7 @@ fn test_leader_restart_validator_start_from_old_ledger() {
|
|||
let val_fullnode = FullNode::new(
|
||||
validator,
|
||||
false,
|
||||
Ledger::Path(stale_ledger_path.clone()),
|
||||
LedgerFile::Path(stale_ledger_path.clone()),
|
||||
Some(keypair),
|
||||
Some(leader_data.contact_info.ncp),
|
||||
);
|
||||
|
@ -356,7 +373,13 @@ fn test_multi_node_dynamic_network() {
|
|||
let bob_pubkey = KeyPair::new().pubkey();
|
||||
let (alice, ledger_path) = genesis(100_000);
|
||||
let leader_data = leader.data.clone();
|
||||
let server = FullNode::new(leader, true, Ledger::Path(ledger_path.clone()), None, None);
|
||||
let server = FullNode::new(
|
||||
leader,
|
||||
true,
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
info!("{:x} LEADER", leader_data.debug_id());
|
||||
let leader_balance =
|
||||
send_tx_and_retry_get_balance(&leader_data, &alice, &bob_pubkey, Some(500)).unwrap();
|
||||
|
@ -378,7 +401,7 @@ fn test_multi_node_dynamic_network() {
|
|||
let val = FullNode::new(
|
||||
validator,
|
||||
false,
|
||||
Ledger::Path(ledger_path.clone()),
|
||||
LedgerFile::Path(ledger_path.clone()),
|
||||
Some(keypair),
|
||||
Some(leader_data.contact_info.ncp),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue