2019-03-07 23:50:12 +00:00
|
|
|
use clap::{App, Arg, SubCommand};
|
2019-02-28 12:13:00 +00:00
|
|
|
use env_logger::{Builder, Env};
|
2019-03-12 01:46:44 +00:00
|
|
|
use gen_keys::gen_keys;
|
2019-03-07 23:50:12 +00:00
|
|
|
use run_test::run_test;
|
2019-03-12 03:39:16 +00:00
|
|
|
use std::fs;
|
|
|
|
use types::test_utils::keypairs_path;
|
2019-03-08 02:18:02 +00:00
|
|
|
use types::ChainSpec;
|
2019-02-28 12:13:00 +00:00
|
|
|
|
|
|
|
mod beacon_chain_harness;
|
2019-03-12 01:46:44 +00:00
|
|
|
mod gen_keys;
|
2019-03-07 23:50:12 +00:00
|
|
|
mod run_test;
|
2019-03-03 04:12:19 +00:00
|
|
|
mod test_case;
|
2019-02-28 12:13:00 +00:00
|
|
|
mod validator_harness;
|
|
|
|
|
2019-03-02 07:59:47 +00:00
|
|
|
use validator_harness::ValidatorHarness;
|
|
|
|
|
2019-02-28 12:13:00 +00:00
|
|
|
fn main() {
|
2019-03-12 03:39:16 +00:00
|
|
|
let validator_file_path = keypairs_path();
|
|
|
|
|
2019-03-12 03:42:31 +00:00
|
|
|
let _ = fs::create_dir(validator_file_path.parent().unwrap());
|
2019-03-12 03:39:16 +00:00
|
|
|
|
2019-02-28 12:13:00 +00:00
|
|
|
let matches = App::new("Lighthouse Test Harness Runner")
|
|
|
|
.version("0.0.1")
|
|
|
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
2019-03-03 04:12:19 +00:00
|
|
|
.about("Runs `test_harness` using a YAML test_case.")
|
2019-03-03 05:15:00 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("log")
|
|
|
|
.long("log-level")
|
2019-03-08 02:18:02 +00:00
|
|
|
.short("l")
|
2019-03-03 05:15:00 +00:00
|
|
|
.value_name("LOG_LEVEL")
|
|
|
|
.help("Logging level.")
|
|
|
|
.possible_values(&["error", "warn", "info", "debug", "trace"])
|
|
|
|
.default_value("debug")
|
|
|
|
.required(true),
|
|
|
|
)
|
2019-03-08 02:18:02 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("spec")
|
|
|
|
.long("spec")
|
|
|
|
.short("s")
|
|
|
|
.value_name("SPECIFICATION")
|
|
|
|
.help("ChainSpec instantiation.")
|
|
|
|
.possible_values(&["foundation", "few_validators"])
|
|
|
|
.default_value("foundation"),
|
|
|
|
)
|
2019-03-07 23:50:12 +00:00
|
|
|
.subcommand(
|
|
|
|
SubCommand::with_name("run_test")
|
|
|
|
.about("Executes a YAML test specification")
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("yaml")
|
|
|
|
.long("yaml")
|
|
|
|
.value_name("FILE")
|
|
|
|
.help("YAML file test_case.")
|
|
|
|
.required(true),
|
2019-03-08 02:18:02 +00:00
|
|
|
)
|
|
|
|
.arg(
|
|
|
|
Arg::with_name("validators_dir")
|
|
|
|
.long("validators-dir")
|
|
|
|
.short("v")
|
|
|
|
.value_name("VALIDATORS_DIR")
|
|
|
|
.help("A directory with validator deposits and keypair YAML."),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.subcommand(
|
2019-03-12 01:46:44 +00:00
|
|
|
SubCommand::with_name("gen_keys")
|
|
|
|
.about("Builds a file of BLS keypairs for faster tests.")
|
2019-03-08 02:18:02 +00:00
|
|
|
.arg(
|
|
|
|
Arg::with_name("validator_count")
|
|
|
|
.long("validator_count")
|
|
|
|
.short("n")
|
|
|
|
.value_name("VALIDATOR_COUNT")
|
|
|
|
.help("Number of validators to generate.")
|
|
|
|
.required(true),
|
|
|
|
)
|
|
|
|
.arg(
|
2019-03-12 01:46:44 +00:00
|
|
|
Arg::with_name("output_file")
|
|
|
|
.long("output_file")
|
2019-03-08 02:18:02 +00:00
|
|
|
.short("d")
|
|
|
|
.value_name("GENESIS_TIME")
|
|
|
|
.help("Output directory for generated YAML.")
|
2019-03-12 03:39:16 +00:00
|
|
|
.default_value(validator_file_path.to_str().unwrap()),
|
2019-03-07 23:50:12 +00:00
|
|
|
),
|
|
|
|
)
|
2019-02-28 12:13:00 +00:00
|
|
|
.get_matches();
|
|
|
|
|
2019-03-03 05:15:00 +00:00
|
|
|
if let Some(log_level) = matches.value_of("log") {
|
|
|
|
Builder::from_env(Env::default().default_filter_or(log_level)).init();
|
|
|
|
}
|
2019-02-28 12:13:00 +00:00
|
|
|
|
2019-03-12 01:46:44 +00:00
|
|
|
let _spec = match matches.value_of("spec") {
|
2019-03-08 02:18:02 +00:00
|
|
|
Some("foundation") => ChainSpec::foundation(),
|
|
|
|
Some("few_validators") => ChainSpec::few_validators(),
|
|
|
|
_ => unreachable!(), // Has a default value, should always exist.
|
|
|
|
};
|
|
|
|
|
2019-03-07 23:50:12 +00:00
|
|
|
if let Some(matches) = matches.subcommand_matches("run_test") {
|
|
|
|
run_test(matches);
|
2019-02-28 12:13:00 +00:00
|
|
|
}
|
2019-03-08 02:18:02 +00:00
|
|
|
|
2019-03-12 01:46:44 +00:00
|
|
|
if let Some(matches) = matches.subcommand_matches("gen_keys") {
|
|
|
|
gen_keys(matches);
|
2019-03-08 02:18:02 +00:00
|
|
|
}
|
2019-02-28 12:13:00 +00:00
|
|
|
}
|