diff --git a/substrate/primitives/weights/src/weight_v2.rs b/substrate/primitives/weights/src/weight_v2.rs index a8eaf79a28..8596a782c1 100644 --- a/substrate/primitives/weights/src/weight_v2.rs +++ b/substrate/primitives/weights/src/weight_v2.rs @@ -318,7 +318,7 @@ impl Zero for Weight { } fn is_zero(&self) -> bool { - self.ref_time == 0 + self == &Self::zero() } } @@ -447,3 +447,16 @@ impl SubAssign for Weight { }; } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn is_zero_works() { + assert!(Weight::zero().is_zero()); + assert!(!Weight::from_components(1, 0).is_zero()); + assert!(!Weight::from_components(0, 1).is_zero()); + assert!(!Weight::MAX.is_zero()); + } +}