Skip to content

Commit

Permalink
add tests, rename config flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pinkiebell committed Oct 18, 2022
1 parent 0a2282c commit 83fb116
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
5 changes: 3 additions & 2 deletions beacon_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,10 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(false)
)
.arg(
Arg::with_name("disable-eth1-sync")
.long("disable-eth1-sync")
Arg::with_name("disable-deposit-contract-sync")
.long("disable-deposit-contract-sync")
.help("Explictly disables the eth1 service. \
This overrides any previous option that depend on it. \
Useful if you intend to run a non-validating beacon node.")
.takes_value(false)
)
Expand Down
3 changes: 2 additions & 1 deletion beacon_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,8 @@ pub fn get_config<E: EthSpec>(
client_config.chain.enable_lock_timeouts = false;
}

if cli_args.is_present("disable-eth1-sync") {
// Note: This overrides any previous flags that enable this option.
if cli_args.is_present("disable-deposit-contract-sync") {
client_config.sync_eth1_chain = false;
}

Expand Down
34 changes: 34 additions & 0 deletions lighthouse/tests/beacon_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,3 +1527,37 @@ fn enabled_disable_log_timestamp_flag() {
assert!(config.logger_config.disable_log_timestamp);
});
}

#[test]
fn sync_eth1_chain_default() {
CommandLineTest::new()
.run_with_zero_port()
.with_config(|config| assert_eq!(config.sync_eth1_chain, false));
}

#[test]
fn sync_eth1_chain_execution_endpoints_flag() {
let dir = TempDir::new().expect("Unable to create temporary directory");
CommandLineTest::new()
.flag("execution-endpoints", Some("http://localhost:8551/"))
.flag(
"execution-jwt",
dir.path().join("jwt-file").as_os_str().to_str(),
)
.run_with_zero_port()
.with_config(|config| assert_eq!(config.sync_eth1_chain, true));
}

#[test]
fn sync_eth1_chain_disable_deposit_contract_sync_flag() {
let dir = TempDir::new().expect("Unable to create temporary directory");
CommandLineTest::new()
.flag("disable-deposit-contract-sync", None)
.flag("execution-endpoints", Some("http://localhost:8551/"))
.flag(
"execution-jwt",
dir.path().join("jwt-file").as_os_str().to_str(),
)
.run_with_zero_port()
.with_config(|config| assert_eq!(config.sync_eth1_chain, false));
}

0 comments on commit 83fb116

Please sign in to comment.