mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-23 14:54:45 +00:00
Strip out old code
All of these files have been moved to either: - https://github.com/sigp/lighthouse-beacon - https://github.com/sigp/lighthouse-validator - https://github.com/sigp/lighthouse-common For rationale, see: https://github.com/sigp/lighthouse/issues/197
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
use super::SlotClock;
|
||||
use std::sync::RwLock;
|
||||
use types::Slot;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {}
|
||||
|
||||
/// Determines the present slot based upon the present system time.
|
||||
pub struct TestingSlotClock {
|
||||
slot: RwLock<u64>,
|
||||
}
|
||||
|
||||
impl TestingSlotClock {
|
||||
/// Create a new `TestingSlotClock`.
|
||||
///
|
||||
/// Returns an Error if `slot_duration_seconds == 0`.
|
||||
pub fn new(slot: u64) -> TestingSlotClock {
|
||||
TestingSlotClock {
|
||||
slot: RwLock::new(slot),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_slot(&self, slot: u64) {
|
||||
*self.slot.write().expect("TestingSlotClock poisoned.") = slot;
|
||||
}
|
||||
}
|
||||
|
||||
impl SlotClock for TestingSlotClock {
|
||||
type Error = Error;
|
||||
|
||||
fn present_slot(&self) -> Result<Option<Slot>, Error> {
|
||||
let slot = *self.slot.read().expect("TestingSlotClock poisoned.");
|
||||
Ok(Some(Slot::new(slot)))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_slot_now() {
|
||||
let clock = TestingSlotClock::new(10);
|
||||
assert_eq!(clock.present_slot(), Ok(Some(Slot::new(10))));
|
||||
clock.set_slot(123);
|
||||
assert_eq!(clock.present_slot(), Ok(Some(Slot::new(123))));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user