@@ -757,13 +757,8 @@ fn mint_without_collateral() {
757
757
} ) ;
758
758
}
759
759
760
- #[ ignore]
761
760
#[ test]
762
761
fn mint_more_than_fixed_can_represent ( ) {
763
- // denomination is 10
764
- // capacity of I75F53 is 1.8+e22
765
- // -> we need to get beyond 1.8+e32
766
- // check that we can still burn afterwards
767
762
let pool_id: AccountIdOf < Test > = calculate_pool_id ( & [ DEFAULT_BONDED_CURRENCY_ID ] ) ;
768
763
769
764
let curve = Curve :: Polynomial ( PolynomialParameters {
@@ -772,7 +767,11 @@ fn mint_more_than_fixed_can_represent() {
772
767
o : Float :: from_num ( 0.1 ) ,
773
768
} ) ;
774
769
775
- let amount_to_mint = 10u128 . pow ( 20 ) ;
770
+ // capacity of I75F53 is (2^74)-1
771
+ // denomination is 10
772
+ // -> minting 2^74 * 10^10 coins would just barely overflow
773
+ // we do it in two tranches, first should work, second should fail
774
+ let amount_to_mint = 2u128 . pow ( 74 ) * 10u128 . pow ( 10 ) / 2 ;
776
775
777
776
ExtBuilder :: default ( )
778
777
. with_native_balances ( vec ! [ ( ACCOUNT_00 , ONE_HUNDRED_KILT ) ] )
@@ -799,28 +798,32 @@ fn mint_more_than_fixed_can_represent() {
799
798
. build_and_execute_with_sanity_tests ( || {
800
799
let origin: OriginFor < Test > = RawOrigin :: Signed ( ACCOUNT_00 ) . into ( ) ;
801
800
802
- // repeatedly mint until we hit balance that cannot be represented
803
- let mut result = Ok ( ( ) . into ( ) ) ;
804
- let mut mints = 0 ;
805
- while result. is_ok ( ) {
806
- result = BondingPallet :: mint_into (
801
+ assert_ok ! ( BondingPallet :: mint_into(
802
+ origin. clone( ) ,
803
+ pool_id. clone( ) ,
804
+ 0 ,
805
+ ACCOUNT_00 ,
806
+ amount_to_mint,
807
+ u128 :: MAX ,
808
+ 1 ,
809
+ ) ) ;
810
+
811
+ assert_err ! (
812
+ BondingPallet :: mint_into(
807
813
origin. clone( ) ,
808
814
pool_id. clone( ) ,
809
815
0 ,
810
816
ACCOUNT_00 ,
811
817
amount_to_mint,
812
818
u128 :: MAX ,
813
819
1 ,
814
- ) ;
815
- mints += 1 ;
816
- }
817
-
818
- assert ! ( mints > 2 ) ;
819
- assert_err ! ( result, ArithmeticError :: Overflow ) ;
820
+ ) ,
821
+ ArithmeticError :: Overflow
822
+ ) ;
820
823
821
824
assert_eq ! (
822
825
Assets :: total_balance( DEFAULT_BONDED_CURRENCY_ID , & ACCOUNT_00 ) ,
823
- amount_to_mint * ( mints - 1 )
826
+ amount_to_mint
824
827
) ;
825
828
826
829
// Make sure the pool is not stuck
0 commit comments