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" } environment = { path = "../lighthouse/environment" }
web3 = "0.8.0" web3 = "0.8.0"
eth2_testnet = { path = "../eth2/utils/eth2_testnet" } eth2_testnet = { path = "../eth2/utils/eth2_testnet" }
dirs = "2.0"

View File

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

View File

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