From f6724acb2c6eb634039b7ba20f916b2e17a6e69c Mon Sep 17 00:00:00 2001 From: Malik672 Date: Wed, 10 Jan 2024 09:13:53 +0100 Subject: [PATCH] implement suggested fixes --- src/entities/fractions/currency_amount.rs | 4 ++-- src/entities/fractions/fraction.rs | 8 ++++---- src/entities/fractions/price.rs | 2 -- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/entities/fractions/currency_amount.rs b/src/entities/fractions/currency_amount.rs index 6d14933..35c436d 100644 --- a/src/entities/fractions/currency_amount.rs +++ b/src/entities/fractions/currency_amount.rs @@ -202,7 +202,7 @@ mod tests { #[should_panic(expected = "AMOUNT")] fn test_token_amount_exceeds_max_uint256() { let _w = CurrencyAmount::from_raw_amount(TOKEN18.clone(), MAX_UINT256.clone() + 1); - assert!(!_w.is_err(), "AMOUNT"); + assert!(_w.is_ok(), "AMOUNT"); } #[test] @@ -210,7 +210,7 @@ mod tests { fn test_token_amount_quotient_exceeds_max_uint256() { let numerator: BigInt = (MAX_UINT256.clone() + 1) * 2; let _w = CurrencyAmount::from_fractional_amount(TOKEN18.clone(), numerator, 2); - assert!(!_w.is_err(), "AMOUNT"); + assert!(_w.is_ok(), "AMOUNT"); } #[test] diff --git a/src/entities/fractions/fraction.rs b/src/entities/fractions/fraction.rs index 1f609b5..bff3f87 100644 --- a/src/entities/fractions/fraction.rs +++ b/src/entities/fractions/fraction.rs @@ -309,8 +309,8 @@ mod tests { #[test] fn test_less_than() { assert!(Fraction::new(1, 10).unwrap() < Fraction::new(4, 12).unwrap()); - assert!(!(Fraction::new(1, 3).unwrap() < Fraction::new(4, 12).unwrap())); - assert!(!(Fraction::new(5, 12).unwrap() < Fraction::new(4, 12).unwrap())); + assert!(Fraction::new(1, 3).unwrap() >= Fraction::new(4, 12).unwrap()); + assert!(Fraction::new(5, 12).unwrap() >= Fraction::new(4, 12).unwrap()); } #[test] @@ -322,8 +322,8 @@ mod tests { #[test] fn test_greater_than() { - assert!(!(Fraction::new(1, 10).unwrap() > Fraction::new(4, 12).unwrap())); - assert!(!(Fraction::new(1, 3).unwrap() > Fraction::new(4, 12).unwrap())); + assert!(Fraction::new(1, 10).unwrap() <= Fraction::new(4, 12).unwrap()); + assert!(Fraction::new(1, 3).unwrap() <= Fraction::new(4, 12).unwrap()); assert!(Fraction::new(5, 12).unwrap() > Fraction::new(4, 12).unwrap()); } diff --git a/src/entities/fractions/price.rs b/src/entities/fractions/price.rs index 502a2e2..42ce0de 100644 --- a/src/entities/fractions/price.rs +++ b/src/entities/fractions/price.rs @@ -14,8 +14,6 @@ where pub base_currency: TBase, pub quote_currency: TQuote, pub scalar: Fraction, - - } impl Price