mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
Remove multiply_by_rational (#11598)
* Removed multiply_by_rational Replaced with multiply_by_rational_with_rounding * fixes * Test Fixes * nightly fmt * Test Fix * Fixed fuzzer.
This commit is contained in:
+9
-7
@@ -16,19 +16,21 @@
|
||||
// limitations under the License.
|
||||
|
||||
//! # Running
|
||||
//! Running this fuzzer can be done with `cargo hfuzz run multiply_by_rational`. `honggfuzz` CLI
|
||||
//! options can be used by setting `HFUZZ_RUN_ARGS`, such as `-n 4` to use 4 threads.
|
||||
//! Running this fuzzer can be done with `cargo hfuzz run multiply_by_rational_with_rounding`.
|
||||
//! `honggfuzz` CLI options can be used by setting `HFUZZ_RUN_ARGS`, such as `-n 4` to use 4
|
||||
//! threads.
|
||||
//!
|
||||
//! # Debugging a panic
|
||||
//! Once a panic is found, it can be debugged with
|
||||
//! `cargo hfuzz run-debug multiply_by_rational hfuzz_workspace/multiply_by_rational/*.fuzz`.
|
||||
//! `cargo hfuzz run-debug multiply_by_rational_with_rounding
|
||||
//! hfuzz_workspace/multiply_by_rational_with_rounding/*.fuzz`.
|
||||
//!
|
||||
//! # More information
|
||||
//! More information about `honggfuzz` can be found
|
||||
//! [here](https://docs.rs/honggfuzz/).
|
||||
|
||||
use honggfuzz::fuzz;
|
||||
use sp_arithmetic::{helpers_128bit::multiply_by_rational, traits::Zero};
|
||||
use sp_arithmetic::{helpers_128bit::multiply_by_rational_with_rounding, traits::Zero, Rounding};
|
||||
|
||||
fn main() {
|
||||
loop {
|
||||
@@ -42,9 +44,9 @@ fn main() {
|
||||
|
||||
println!("++ Equation: {} * {} / {}", a, b, c);
|
||||
|
||||
// The point of this fuzzing is to make sure that `multiply_by_rational` is 100%
|
||||
// accurate as long as the value fits in a u128.
|
||||
if let Ok(result) = multiply_by_rational(a, b, c) {
|
||||
// The point of this fuzzing is to make sure that `multiply_by_rational_with_rounding`
|
||||
// is 100% accurate as long as the value fits in a u128.
|
||||
if let Some(result) = multiply_by_rational_with_rounding(a, b, c, Rounding::Down) {
|
||||
let truth = mul_div(a, b, c);
|
||||
|
||||
if result != truth && result != truth + 1 {
|
||||
Reference in New Issue
Block a user