From 6d6e15857fd0a73def283d4486c5decd896b662f Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli <> Date: Mon, 22 Jan 2024 11:17:29 +0100 Subject: [PATCH] fix two third over two third nay --- crates/governance/src/utils.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/governance/src/utils.rs b/crates/governance/src/utils.rs index 84bdeb708bf..9c70ddf51e5 100644 --- a/crates/governance/src/utils.rs +++ b/crates/governance/src/utils.rs @@ -198,9 +198,9 @@ impl ProposalResult { + self.total_abstain_power >= self.total_voting_power.mul_ceil(Dec::two() / 3); - let at_least_two_thirds_voted_nay = - self.total_nay_power.mul_ceil(Dec::two() / 3) - >= (self.total_yay_power + self.total_nay_power); + let at_least_two_thirds_voted_nay = self.total_nay_power + >= (self.total_yay_power + self.total_nay_power) + .mul_ceil(Dec::two() / 3); at_least_two_third_voted && at_least_two_thirds_voted_nay } @@ -1345,6 +1345,8 @@ mod test { token::Amount::zero(), "abstain" ); + + assert_eq!(proposal_result.two_thirds_nay_over_two_thirds_total(), true) } #[test] @@ -1399,5 +1401,10 @@ mod test { token::Amount::zero(), "abstain" ); + + assert_eq!( + proposal_result.two_thirds_nay_over_two_thirds_total(), + false + ) } }