Skip to content

Commit

Permalink
Add epoch trait (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 19, 2022
1 parent 3fcb800 commit f8ae218
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/command/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub(crate) fn run(ordinal: Ordinal) -> Result {
println!("character: {:?}", character);
}

println!("epoch: {}", ordinal.epoch());

println!("height: {}", ordinal.height());

if ordinal.subsidy_position() == 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/epoch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::*;

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Display)]
pub(crate) struct Epoch(pub(crate) u64);

impl Epoch {
Expand Down
11 changes: 10 additions & 1 deletion tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fn name() -> Result {
}

#[test]
fn block() -> Result {
fn height() -> Result {
assert!(traits(0)?.contains("height: 0"));
assert!(traits(1)?.contains("height: 0"));
assert!(traits(50 * 100_000_000)?.contains("height: 1"));
Expand All @@ -93,6 +93,15 @@ fn block() -> Result {
Ok(())
}

#[test]
fn epoch() -> Result {
assert!(traits(0)?.contains("epoch: 0"));
assert!(traits(1)?.contains("epoch: 0"));
assert!(traits(50 * 100_000_000 * 210000)?.contains("epoch: 1"));
assert!(traits(2099999997689999)?.contains("epoch: 32"));
Ok(())
}

#[test]
fn lucky() -> Result {
assert!(traits(0)?.contains("luck: 0/1"));
Expand Down

0 comments on commit f8ae218

Please sign in to comment.