Skip to content

Commit

Permalink
add test for update_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ctindogarus4f committed Jan 14, 2022
1 parent 6b8ce2a commit 67893cf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions sputnikdao2/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,39 @@ mod tests {
policy.default_vote_policy.threshold
);
}

#[test]
fn test_update_parameters() {
let council = vec![accounts(0), accounts(1)];
let mut policy = default_policy(council);

assert_eq!(U128(10u128.pow(24)), policy.proposal_bond);
assert_eq!(
U64::from(1_000_000_000 * 60 * 60 * 24 * 7),
policy.proposal_period
);
assert_eq!(U128(10u128.pow(24)), policy.bounty_bond);
assert_eq!(
U64::from(1_000_000_000 * 60 * 60 * 24),
policy.bounty_forgiveness_period
);

let new_parameters = PolicyParameters {
proposal_bond: Some(U128(10u128.pow(26))),
proposal_period: None,
bounty_bond: None,
bounty_forgiveness_period: Some(U64::from(1_000_000_000 * 60 * 60 * 24 * 5)),
};
policy.update_parameters(&new_parameters);
assert_eq!(U128(10u128.pow(26)), policy.proposal_bond);
assert_eq!(
U64::from(1_000_000_000 * 60 * 60 * 24 * 7),
policy.proposal_period
);
assert_eq!(U128(10u128.pow(24)), policy.bounty_bond);
assert_eq!(
U64::from(1_000_000_000 * 60 * 60 * 24 * 5),
policy.bounty_forgiveness_period
);
}
}

0 comments on commit 67893cf

Please sign in to comment.