Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions common/slot_clock/src/manual_slot_clock.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use super::SlotClock;
use parking_lot::RwLock;
use std::convert::TryInto;
use std::sync::Arc;
use std::time::Duration;
use types::Slot;

Expand All @@ -10,7 +11,7 @@ pub struct ManualSlotClock {
/// Duration from UNIX epoch to genesis.
genesis_duration: Duration,
/// Duration from UNIX epoch to right now.
current_time: RwLock<Duration>,
current_time: Arc<RwLock<Duration>>,
/// The length of each slot.
slot_duration: Duration,
}
Expand All @@ -20,7 +21,7 @@ impl Clone for ManualSlotClock {
ManualSlotClock {
genesis_slot: self.genesis_slot,
genesis_duration: self.genesis_duration,
current_time: RwLock::new(*self.current_time.read()),
current_time: Arc::clone(&self.current_time),
slot_duration: self.slot_duration,
}
}
Expand Down Expand Up @@ -90,7 +91,7 @@ impl SlotClock for ManualSlotClock {

Self {
genesis_slot,
current_time: RwLock::new(genesis_duration),
current_time: Arc::new(RwLock::new(genesis_duration)),
genesis_duration,
slot_duration,
}
Expand Down
34 changes: 18 additions & 16 deletions lighthouse/tests/beacon_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ fn slasher_slot_offset_flag() {
CommandLineTest::new()
.flag("slasher", None)
.flag("slasher-slot-offset", Some("11.25"))
.run()
.run_with_zero_port()
.with_config(|config| {
let slasher_config = config.slasher.as_ref().unwrap();
assert_eq!(slasher_config.slot_offset, 11.25);
Expand All @@ -1430,7 +1430,7 @@ fn slasher_slot_offset_nan_flag() {
CommandLineTest::new()
.flag("slasher", None)
.flag("slasher-slot-offset", Some("NaN"))
.run();
.run_with_zero_port();
}
#[test]
fn slasher_history_length_flag() {
Expand Down Expand Up @@ -1465,7 +1465,7 @@ fn slasher_attestation_cache_size_flag() {
CommandLineTest::new()
.flag("slasher", None)
.flag("slasher-att-cache-size", Some("10000"))
.run()
.run_with_zero_port()
.with_config(|config| {
let slasher_config = config
.slasher
Expand Down Expand Up @@ -1569,39 +1569,41 @@ fn ensure_panic_on_failed_launch() {

#[test]
fn enable_proposer_re_orgs_default() {
CommandLineTest::new().run().with_config(|config| {
assert_eq!(
config.chain.re_org_threshold,
Some(DEFAULT_RE_ORG_THRESHOLD)
);
assert_eq!(
config.chain.re_org_max_epochs_since_finalization,
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
);
});
CommandLineTest::new()
.run_with_zero_port()
.with_config(|config| {
assert_eq!(
config.chain.re_org_threshold,
Some(DEFAULT_RE_ORG_THRESHOLD)
);
assert_eq!(
config.chain.re_org_max_epochs_since_finalization,
DEFAULT_RE_ORG_MAX_EPOCHS_SINCE_FINALIZATION,
);
});
}

#[test]
fn disable_proposer_re_orgs() {
CommandLineTest::new()
.flag("disable-proposer-reorgs", None)
.run()
.run_with_zero_port()
.with_config(|config| assert_eq!(config.chain.re_org_threshold, None));
}

#[test]
fn proposer_re_org_threshold() {
CommandLineTest::new()
.flag("proposer-reorg-threshold", Some("90"))
.run()
.run_with_zero_port()
.with_config(|config| assert_eq!(config.chain.re_org_threshold.unwrap().0, 90));
}

#[test]
fn proposer_re_org_max_epochs_since_finalization() {
CommandLineTest::new()
.flag("proposer-reorg-epochs-since-finalization", Some("8"))
.run()
.run_with_zero_port()
.with_config(|config| {
assert_eq!(
config.chain.re_org_max_epochs_since_finalization.as_u64(),
Expand Down