Fix lcli testnet deployer

This commit is contained in:
Paul Hauner
2019-11-24 19:20:09 +11:00
parent 2fdd130f4c
commit 7dba4841dc
3 changed files with 16 additions and 5 deletions

View File

@@ -23,3 +23,4 @@ futures = "0.1.25"
environment = { path = "../lighthouse/environment" }
web3 = "0.8.0"
eth2_testnet = { path = "../eth2/utils/eth2_testnet" }
dirs = "2.0"

View File

@@ -159,8 +159,7 @@ fn main() {
.short("o")
.value_name("PATH")
.takes_value(true)
.default_value("~/.lighthouse/testnet")
.help("The output directory."),
.help("The output directory. Defaults to ~/.lighthouse/testnet"),
)
.arg(
Arg::with_name("min_genesis_time")

View File

@@ -6,6 +6,8 @@ use std::path::PathBuf;
use types::EthSpec;
use web3::{transports::Http, Web3};
pub const DEFAULT_DATA_DIR: &str = ".lighthouse/testnet";
pub fn new_testnet<T: EthSpec>(
mut env: Environment<T>,
matches: &ArgMatches,
@@ -24,9 +26,16 @@ pub fn new_testnet<T: EthSpec>(
let output_dir = matches
.value_of("output")
.ok_or_else(|| "Output directory not specified")?
.parse::<PathBuf>()
.map_err(|e| format!("Failed to parse output directory: {}", e))?;
.ok_or_else(|| ())
.and_then(|output| output.parse::<PathBuf>().map_err(|_| ()))
.unwrap_or_else(|_| {
dirs::home_dir()
.map(|mut home| {
home.push(DEFAULT_DATA_DIR);
home
})
.expect("should locate home directory")
});
let endpoint = matches
.value_of("endpoint")
@@ -73,6 +82,8 @@ pub fn new_testnet<T: EthSpec>(
deploy_block
);
info!("Writing config to {:?}", output_dir);
Eth2TestnetDir::new(
output_dir,
format!("0x{}", deposit_contract.address()),