diff --git a/packages/std/src/math/decimal.rs b/packages/std/src/math/decimal.rs index d4c63651bd..5f1473dfd0 100644 --- a/packages/std/src/math/decimal.rs +++ b/packages/std/src/math/decimal.rs @@ -2072,6 +2072,19 @@ mod tests { let d = Decimal::MAX; assert_eq!(d.to_uint_floor(), Uint128::new(340282366920938463463)); + + // Does the same as the old workaround `Uint128::one() * my_decimal`. + // This block can be deleted as part of https://github.com/CosmWasm/cosmwasm/issues/1485. + let tests = vec![ + Decimal::from_str("12.345").unwrap(), + Decimal::from_str("0.98451384").unwrap(), + Decimal::from_str("178.0").unwrap(), + Decimal::MIN, + Decimal::MAX, + ]; + for my_decimal in tests.into_iter() { + assert_eq!(my_decimal.to_uint_floor(), Uint128::one() * my_decimal); + } } #[test] diff --git a/packages/std/src/math/decimal256.rs b/packages/std/src/math/decimal256.rs index 45e7e8d83a..1092776c68 100644 --- a/packages/std/src/math/decimal256.rs +++ b/packages/std/src/math/decimal256.rs @@ -2223,6 +2223,19 @@ mod tests { Uint256::from_str("115792089237316195423570985008687907853269984665640564039457") .unwrap() ); + + // Does the same as the old workaround `Uint256::one() * my_decimal`. + // This block can be deleted as part of https://github.com/CosmWasm/cosmwasm/issues/1485. + let tests = vec![ + Decimal256::from_str("12.345").unwrap(), + Decimal256::from_str("0.98451384").unwrap(), + Decimal256::from_str("178.0").unwrap(), + Decimal256::MIN, + Decimal256::MAX, + ]; + for my_decimal in tests.into_iter() { + assert_eq!(my_decimal.to_uint_floor(), Uint256::one() * my_decimal); + } } #[test]