Skip to content

Commit d1d6442

Browse files
committed
Update lighthouse/tests
1 parent f935b9f commit d1d6442

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

lighthouse/tests/validator_manager.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ pub fn validator_exit_defaults() {
491491
Some(&format!("{},{}", EXAMPLE_PUBKEY_0, EXAMPLE_PUBKEY_1)),
492492
)
493493
.flag("--vc-token", Some("./token.json"))
494+
.flag("--beacon-node", Some("http://localhost:5052"))
494495
.assert_success(|config| {
495496
let expected = ExitConfig {
496497
vc_url: SensitiveUrl::parse("http://localhost:5062").unwrap(),
@@ -499,7 +500,7 @@ pub fn validator_exit_defaults() {
499500
PublicKeyBytes::from_str(EXAMPLE_PUBKEY_0).unwrap(),
500501
PublicKeyBytes::from_str(EXAMPLE_PUBKEY_1).unwrap(),
501502
],
502-
beacon_url: None,
503+
beacon_url: Some(SensitiveUrl::parse("http://localhost:5052").unwrap()),
503504
exit_epoch: None,
504505
signature: false,
505506
exit_status: false,

validator_manager/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ http_api = { workspace = true }
3030
regex = { workspace = true }
3131
tempfile = { workspace = true }
3232
validator_http_api = { workspace = true }
33-

validator_manager/src/exit_validators.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl ExitConfig {
106106
fn from_cli(matches: &ArgMatches) -> Result<Self, String> {
107107
let validators_to_exit_str = clap_utils::parse_required::<String>(matches, VALIDATOR_FLAG)?;
108108

109+
// Keyword "all" to exit all validators, vector to be created later
109110
let validators_to_exit = if validators_to_exit_str.trim() == "all" {
110111
Vec::new()
111112
} else {
@@ -153,7 +154,6 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
153154

154155
let (http_client, validators) = vc_http_client(vc_url.clone(), &vc_token_path).await?;
155156

156-
// Exit all validators on the VC
157157
if validators_to_exit.is_empty() {
158158
validators_to_exit = validators.iter().map(|v| v.validating_pubkey).collect();
159159
}
@@ -180,7 +180,7 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
180180
}
181181
}
182182

183-
// only publish the voluntary exit if the --beacon-node flag is present
183+
// Only publish the voluntary exit if the --beacon-node flag is present
184184
if beacon_url.is_some() {
185185
let beacon_node = if let Some(ref beacon_url) = beacon_url {
186186
BeaconNodeHttpClient::new(
@@ -238,32 +238,29 @@ async fn run<E: EthSpec>(config: ExitConfig) -> Result<(), String> {
238238
.ok_or("Failed to get current epoch. Please check your system time")?;
239239

240240
// Check if validator is eligible for exit
241-
if !exit_status {
242-
if validator_data.status == ValidatorStatus::ActiveOngoing
243-
&& current_epoch < activation_epoch + spec.shard_committee_period
244-
{
245-
eprintln!(
241+
if validator_data.status == ValidatorStatus::ActiveOngoing
242+
&& current_epoch < activation_epoch + spec.shard_committee_period
243+
{
244+
eprintln!(
246245
"Validator {} is not eligible for exit. It will become eligible at epoch {}",
247246
validator_to_exit,
248247
activation_epoch + spec.shard_committee_period
249248
)
250-
} else if validator_data.status != ValidatorStatus::ActiveOngoing {
251-
eprintln!(
252-
"Validator {} is not eligible for exit. Validator status is: {:?}",
253-
validator_to_exit, validator_data.status
254-
)
255-
} else {
256-
// Only publish voluntary exit if validator status is ActiveOngoing
257-
beacon_node
258-
.post_beacon_pool_voluntary_exits(&exit_message.data)
259-
.await
260-
.map_err(|e| format!("Failed to publish voluntary exit: {}", e))?;
261-
// tokio::time::sleep(std::time::Duration::from_secs(1)).await; // Provides nicer UX.
262-
eprintln!(
263-
"Successfully validated and published voluntary exit for validator {}",
264-
validator_to_exit
265-
);
266-
}
249+
} else if validator_data.status != ValidatorStatus::ActiveOngoing {
250+
eprintln!(
251+
"Validator {} is not eligible for exit. Validator status is: {:?}",
252+
validator_to_exit, validator_data.status
253+
)
254+
} else {
255+
// Only publish voluntary exit if validator status is ActiveOngoing
256+
beacon_node
257+
.post_beacon_pool_voluntary_exits(&exit_message.data)
258+
.await
259+
.map_err(|e| format!("Failed to publish voluntary exit: {}", e))?;
260+
eprintln!(
261+
"Successfully validated and published voluntary exit for validator {}",
262+
validator_to_exit
263+
);
267264
}
268265

269266
// Check validator status after publishing voluntary exit
@@ -332,6 +329,7 @@ fn get_current_epoch<E: EthSpec>(genesis_time: u64, spec: &ChainSpec) -> Option<
332329
);
333330
slot_clock.now().map(|s| s.epoch(E::slots_per_epoch()))
334331
}
332+
335333
#[cfg(not(debug_assertions))]
336334
#[cfg(test)]
337335
mod test {

0 commit comments

Comments
 (0)