mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Add error message for duration subtraction overflow in sim tests (#6558)
* Add error message for duration subtraction overflow.
This commit is contained in:
@@ -206,7 +206,7 @@ pub fn run_basic_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
node.server.all_payloads_valid();
|
||||
});
|
||||
|
||||
let duration_to_genesis = network.duration_to_genesis().await;
|
||||
let duration_to_genesis = network.duration_to_genesis().await?;
|
||||
println!("Duration to genesis: {}", duration_to_genesis.as_secs());
|
||||
sleep(duration_to_genesis).await;
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ pub fn run_fallback_sim(matches: &ArgMatches) -> Result<(), String> {
|
||||
);
|
||||
}
|
||||
|
||||
let duration_to_genesis = network.duration_to_genesis().await;
|
||||
let duration_to_genesis = network.duration_to_genesis().await?;
|
||||
println!("Duration to genesis: {}", duration_to_genesis.as_secs());
|
||||
sleep(duration_to_genesis).await;
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ impl<E: EthSpec> LocalNetwork<E> {
|
||||
.map(|body| body.unwrap().data.finalized.epoch)
|
||||
}
|
||||
|
||||
pub async fn duration_to_genesis(&self) -> Duration {
|
||||
pub async fn duration_to_genesis(&self) -> Result<Duration, &'static str> {
|
||||
let nodes = self.remote_nodes().expect("Failed to get remote nodes");
|
||||
let bootnode = nodes.first().expect("Should contain bootnode");
|
||||
let now = SystemTime::now().duration_since(UNIX_EPOCH).unwrap();
|
||||
@@ -471,6 +471,9 @@ impl<E: EthSpec> LocalNetwork<E> {
|
||||
.data
|
||||
.genesis_time,
|
||||
);
|
||||
genesis_time - now
|
||||
genesis_time.checked_sub(now).ok_or(
|
||||
"The genesis time has already passed since all nodes started. The node startup time \
|
||||
may have regressed, and the current `GENESIS_DELAY` is no longer sufficient.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user