Skip to content

Commit 121c870

Browse files
committed
test: fix test
1 parent ffc5a84 commit 121c870

File tree

1 file changed

+21
-18
lines changed
  • pallets/pallet-bonded-coins/src/tests/transactions

1 file changed

+21
-18
lines changed

pallets/pallet-bonded-coins/src/tests/transactions/mint_into.rs

+21-18
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,8 @@ fn mint_without_collateral() {
757757
});
758758
}
759759

760-
#[ignore]
761760
#[test]
762761
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
767762
let pool_id: AccountIdOf<Test> = calculate_pool_id(&[DEFAULT_BONDED_CURRENCY_ID]);
768763

769764
let curve = Curve::Polynomial(PolynomialParameters {
@@ -772,7 +767,11 @@ fn mint_more_than_fixed_can_represent() {
772767
o: Float::from_num(0.1),
773768
});
774769

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;
776775

777776
ExtBuilder::default()
778777
.with_native_balances(vec![(ACCOUNT_00, ONE_HUNDRED_KILT)])
@@ -799,28 +798,32 @@ fn mint_more_than_fixed_can_represent() {
799798
.build_and_execute_with_sanity_tests(|| {
800799
let origin: OriginFor<Test> = RawOrigin::Signed(ACCOUNT_00).into();
801800

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(
807813
origin.clone(),
808814
pool_id.clone(),
809815
0,
810816
ACCOUNT_00,
811817
amount_to_mint,
812818
u128::MAX,
813819
1,
814-
);
815-
mints += 1;
816-
}
817-
818-
assert!(mints > 2);
819-
assert_err!(result, ArithmeticError::Overflow);
820+
),
821+
ArithmeticError::Overflow
822+
);
820823

821824
assert_eq!(
822825
Assets::total_balance(DEFAULT_BONDED_CURRENCY_ID, &ACCOUNT_00),
823-
amount_to_mint * (mints - 1)
826+
amount_to_mint
824827
);
825828

826829
// Make sure the pool is not stuck

0 commit comments

Comments
 (0)