Add test to guarantee algebraic transform of Weight
What changed, and why it matters
This commit only adds a new unit test. It checks that dividing and taking the remainder of a Weight value can be reversed to get the original value. No code behavior is changed, and no security issue is introduced or fixed.
No action required. This is a benign test-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single test, weight_algebra, in units/src/weight.rs. It constructs two Weight values (700 and 300 wu), computes integer division and remainder, and asserts that quotient * divisor + remainder equals the original dividend. No implementation code is modified.
Changed components
units/src/weight.rs (tests only)Inspect captured patch +10 / −0
diff --git a/units/src/weight.rs b/units/src/weight.rs
index e026e329..9c4961a6 100644
--- a/units/src/weight.rs
+++ b/units/src/weight.rs
@@ -563,6 +563,16 @@ mod tests {
assert_eq!(weight, Weight::from_wu(1));
}
+ #[test]
+ fn weight_algebra() {
+ let a = Weight::from_wu(700);
+ let b = Weight::from_wu(300);
+ let d = a / b;
+ let r = a % b;
+
+ assert_eq!(a, d * b + r);
+ }
+
#[test]
fn iter_sum() {
let values = [
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.