Skip to content

Commit

Permalink
Merge branch '2.0' into refactor/types/remove-address-from-output-data
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars authored Dec 4, 2023
2 parents 45df33c + 4de1bf8 commit 0918e41
Showing 1 changed file with 50 additions and 51 deletions.
101 changes: 50 additions & 51 deletions sdk/src/types/block/mana/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ mod test {
}

#[test]
fn test_mana_decay_no_factors() {
fn mana_decay_no_factors() {
let mana_parameters = ManaParameters {
decay_factors: Box::<[_]>::default().try_into().unwrap(),
..Default::default()
Expand All @@ -266,23 +266,23 @@ mod test {
}

#[test]
fn test_mana_decay_no_delta() {
fn mana_decay_no_delta() {
assert_eq!(
params().mana_with_decay(100, params().first_slot_of(1), params().first_slot_of(1)),
Ok(100)
);
}

#[test]
fn test_mana_decay_no_mana() {
fn mana_decay_no_mana() {
assert_eq!(
params().mana_with_decay(0, params().first_slot_of(1), params().first_slot_of(400)),
Ok(0)
);
}

#[test]
fn test_mana_decay_negative_delta() {
fn mana_decay_negative_delta() {
assert_eq!(
params().mana_with_decay(100, params().first_slot_of(2), params().first_slot_of(1)),
Err(Error::InvalidEpochDelta {
Expand All @@ -293,7 +293,7 @@ mod test {
}

#[test]
fn test_mana_decay_lookup_len_delta() {
fn mana_decay_lookup_len_delta() {
assert_eq!(
params().mana_with_decay(
u64::MAX,
Expand All @@ -305,7 +305,7 @@ mod test {
}

#[test]
fn test_mana_decay_lookup_len_delta_multiple() {
fn mana_decay_lookup_len_delta_multiple() {
assert_eq!(
params().mana_with_decay(
u64::MAX,
Expand All @@ -317,31 +317,31 @@ mod test {
}

#[test]
fn test_mana_decay_max_mana() {
fn mana_decay_max_mana() {
assert_eq!(
params().mana_with_decay(u64::MAX, params().first_slot_of(1), params().first_slot_of(401)),
Ok(13046663022640287317)
);
}

#[test]
fn test_potential_mana_no_delta() {
fn potential_mana_no_delta() {
assert_eq!(
params().potential_mana(100, params().first_slot_of(1), params().first_slot_of(1)),
Ok(0)
);
}

#[test]
fn test_potential_mana_no_mana() {
fn potential_mana_no_mana() {
assert_eq!(
params().potential_mana(0, params().first_slot_of(1), params().first_slot_of(400)),
Ok(0)
);
}

#[test]
fn test_potential_mana_negative_delta() {
fn potential_mana_negative_delta() {
assert_eq!(
params().potential_mana(100, params().first_slot_of(2), params().first_slot_of(1)),
Err(Error::InvalidEpochDelta {
Expand All @@ -351,60 +351,59 @@ mod test {
);
}

// TODO: Uncomment when iota.go fixes their calculation + test data
// #[test]
// fn test_potential_mana_lookup_len_delta() {
// assert_eq!(
// params().potential_mana(
// i64::MAX as u64,
// params().first_slot_of(1),
// params().first_slot_of(params().mana_parameters().decay_factors().len() as u32 + 1)
// ),
// Ok(183827294847826527)
// );
// }

// #[test]
// fn test_potential_mana_lookup_len_delta_multiple() {
// assert_eq!(
// params().potential_mana(
// i64::MAX as u64,
// params().first_slot_of(1),
// params().first_slot_of(3 * params().mana_parameters().decay_factors().len() as u32 + 1)
// ),
// Ok(410192222442040018)
// );
// }
#[test]
fn potential_mana_lookup_len_delta() {
assert_eq!(
params().potential_mana(
i64::MAX as u64,
params().first_slot_of(1),
params().first_slot_of(params().mana_parameters().decay_factors().len() as u32 + 1)
),
Ok(183827295065703076)
);
}

#[test]
fn potential_mana_lookup_len_delta_multiple() {
assert_eq!(
params().potential_mana(
i64::MAX as u64,
params().first_slot_of(1),
params().first_slot_of(3 * params().mana_parameters().decay_factors().len() as u32 + 1)
),
Ok(410192223115924783)
);
}

#[test]
fn test_potential_mana_same_epoch() {
fn potential_mana_same_epoch() {
assert_eq!(
params().potential_mana(i64::MAX as u64, params().first_slot_of(1), params().last_slot_of(1)),
Ok(562881233944575)
);
}

#[test]
fn test_potential_mana_one_epoch() {
fn potential_mana_one_epoch() {
assert_eq!(
params().potential_mana(i64::MAX as u64, params().first_slot_of(1), params().last_slot_of(2)),
Ok(1125343946211326)
);
}

// #[test]
// fn test_potential_mana_several_epochs() {
// assert_eq!(
// params().potential_mana(i64::MAX as u64, params().first_slot_of(1), params().last_slot_of(3)),
// Ok(1687319975062367)
// );
// }

// #[test]
// fn test_potential_mana_max_mana() {
// assert_eq!(
// params().potential_mana(i64::MAX as u64, params().first_slot_of(1), params().first_slot_of(401)),
// Ok(190239292158065300)
// );
// }
#[test]
fn potential_mana_several_epochs() {
assert_eq!(
params().potential_mana(i64::MAX as u64, params().first_slot_of(1), params().last_slot_of(3)),
Ok(1687319824887185)
);
}

#[test]
fn potential_mana_max_mana() {
assert_eq!(
params().potential_mana(i64::MAX as u64, params().first_slot_of(1), params().first_slot_of(401)),
Ok(190239292388858706)
);
}
}

0 comments on commit 0918e41

Please sign in to comment.