mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 14:54:45 +00:00
Merge latest master in v0.2.0
This commit is contained in:
@@ -8,23 +8,29 @@ use std::path::PathBuf;
|
||||
const TESTNET_ID: &str = "testnet5";
|
||||
|
||||
fn main() {
|
||||
match get_all_files() {
|
||||
Ok(()) => (),
|
||||
Err(e) => panic!(e),
|
||||
if !base_dir().exists() {
|
||||
std::fs::create_dir_all(base_dir()).expect(&format!("Unable to create {:?}", base_dir()));
|
||||
|
||||
match get_all_files() {
|
||||
Ok(()) => (),
|
||||
Err(e) => {
|
||||
std::fs::remove_dir_all(base_dir()).expect(&format!(
|
||||
"{}. Failed to remove {:?}, please remove the directory manually because it may contains incomplete testnet data.",
|
||||
e,
|
||||
base_dir(),
|
||||
));
|
||||
panic!(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_all_files() -> Result<(), String> {
|
||||
if !base_dir().exists() {
|
||||
std::fs::create_dir_all(base_dir())
|
||||
.map_err(|e| format!("Unable to create {:?}: {}", base_dir(), e))?;
|
||||
|
||||
get_file("boot_enr.yaml")?;
|
||||
get_file("config.yaml")?;
|
||||
get_file("deploy_block.txt")?;
|
||||
get_file("deposit_contract.txt")?;
|
||||
get_file("genesis.ssz")?;
|
||||
}
|
||||
get_file("boot_enr.yaml")?;
|
||||
get_file("config.yaml")?;
|
||||
get_file("deploy_block.txt")?;
|
||||
get_file("deposit_contract.txt")?;
|
||||
get_file("genesis.ssz")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -156,11 +156,11 @@ impl<E: EthSpec> Eth2TestnetConfig<E> {
|
||||
let yaml_config = optional_load_from_file!(YAML_CONFIG_FILE);
|
||||
|
||||
// The genesis state is a special case because it uses SSZ, not YAML.
|
||||
let file = base_dir.join(GENESIS_STATE_FILE);
|
||||
let genesis_state = if base_dir.join(&file).exists() {
|
||||
let genesis_file_path = base_dir.join(GENESIS_STATE_FILE);
|
||||
let genesis_state = if genesis_file_path.exists() {
|
||||
Some(
|
||||
File::open(base_dir.join(&file))
|
||||
.map_err(|e| format!("Unable to open {:?}: {:?}", file, e))
|
||||
File::open(&genesis_file_path)
|
||||
.map_err(|e| format!("Unable to open {:?}: {:?}", genesis_file_path, e))
|
||||
.and_then(|mut file| {
|
||||
let mut bytes = vec![];
|
||||
file.read_to_end(&mut bytes)
|
||||
@@ -202,6 +202,7 @@ mod tests {
|
||||
|
||||
type E = MainnetEthSpec;
|
||||
|
||||
/* TODO: disabled until testnet config is updated for v0.11
|
||||
#[test]
|
||||
fn hard_coded_works() {
|
||||
let dir: Eth2TestnetConfig<E> =
|
||||
@@ -211,6 +212,7 @@ mod tests {
|
||||
assert!(dir.genesis_state.is_some());
|
||||
assert!(dir.yaml_config.is_some());
|
||||
}
|
||||
*/
|
||||
|
||||
#[test]
|
||||
fn round_trip() {
|
||||
|
||||
Reference in New Issue
Block a user