You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[test(should_fail)]fntest_mul_div_up_zero_divisor(){let a = SafeU120::new(6);let b = SafeU120::new(3);let c = SafeU120::new(0);let _d = SafeU120::mul_div_up(a, b, c);}
It will fail due to a panic. If replacing % with / it will fail due to the assert.
Expected Behavior
Expect to fail due to the assert !divisor.is_zero() similarly to divisions.
Bug
When containing an unreachable modulo computation % divisor with divisor = 0, the program panics instead of failing due to the assert divisor != 0 which is checked earlier.
Aim
In the process of testing a safe-math library (safe_u120.nr) I'm running into a strange thing while testing.
For my
mul_div_up
function as outlined below, I perform a mod operation against user provided input.When running the test:
It will fail due to a panic. If replacing
%
with/
it will fail due to the assert.Expected Behavior
Expect to fail due to the assert
!divisor.is_zero()
similarly to divisions.Bug
When containing an unreachable modulo computation
% divisor
withdivisor = 0
, the program panics instead of failing due to the assertdivisor != 0
which is checked earlier.To Reproduce
test_mul_div_up_zero_divisor
testnargo test
Installation Method
None
Nargo Version
nargo 0.10.5 (git version hash: 5f78772, is dirty: false)
Additional Context
Installed nargo using
noirup -v aztec
.Would you like to submit a PR for this Issue?
No
Support Needs
No response
The text was updated successfully, but these errors were encountered: