Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Oct 26, 2021
1 parent 9fa7d42 commit 8288c94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions modules/homa-lite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ pub mod module {

fn liquid_amount_is_above_minimum_threshold(liquid_amount: Balance) -> bool {
liquid_amount > T::MinimumRedeemThreshold::get()
&& Self::convert_liquid_to_staking(liquid_amount).unwrap_or_default() > T::XcmUnbondFee::get()
}

/// Construct a XCM message
Expand Down
18 changes: 9 additions & 9 deletions modules/homa-lite/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,11 @@ fn request_redeem_works() {
assert_eq!(AvailableStakingBalance::<Runtime>::get(), 0);
assert_eq!(Currencies::free_balance(KSM, &ROOT), dollar(49_998));
assert_eq!(Currencies::free_balance(LKSM, &ROOT), dollar(349_400));
assert_eq!(Currencies::reserved_balance(LKSM, &ROOT), 149_850_000_000_000_000);
assert_eq!(Currencies::reserved_balance(LKSM, &ROOT), 149949400000000000);
// request_redeem replaces existing item in the queue, not add to it.
assert_eq!(
RedeemRequests::<Runtime>::get(&ROOT),
Some((149_850_000_000_000_000, Permill::zero()))
Some((149949400000000000, Permill::zero()))
);
});
}
Expand Down Expand Up @@ -641,10 +641,10 @@ fn can_replace_requested_redeem() {
dollar(50_000),
Permill::from_percent(50)
));
assert_eq!(Currencies::reserved_balance(LKSM, &ROOT), dollar(49_950));
assert_eq!(Currencies::reserved_balance(LKSM, &ROOT), dollar(50_000));
assert_eq!(
RedeemRequests::<Runtime>::get(&ROOT),
Some((dollar(49_950), Permill::from_percent(50)))
Some((dollar(50_000), Permill::from_percent(50)))
);

// Increasing the amount locks additional liquid currency.
Expand All @@ -653,10 +653,10 @@ fn can_replace_requested_redeem() {
dollar(150_000),
Permill::from_percent(10)
));
assert_eq!(Currencies::reserved_balance(LKSM, &ROOT), dollar(149_850));
assert_eq!(Currencies::reserved_balance(LKSM, &ROOT), dollar(149_900));
assert_eq!(
RedeemRequests::<Runtime>::get(&ROOT),
Some((dollar(149_850), Permill::from_percent(10)))
Some((dollar(149_900), Permill::from_percent(10)))
);
});
}
Expand Down Expand Up @@ -938,11 +938,11 @@ fn not_overcharge_redeem_fee() {

assert_ok!(HomaLite::request_redeem(
Origin::signed(ALICE),
dollar(10) - fee * 2,
dollar(20) - fee * 2,
Permill::zero()
));

assert_eq!(Currencies::free_balance(LKSM, &ALICE), dollar(90));
assert_eq!(Currencies::reserved_balance(LKSM, &ALICE), dollar(10) - fee * 2);
assert_eq!(Currencies::free_balance(LKSM, &ALICE), dollar(80));
assert_eq!(Currencies::reserved_balance(LKSM, &ALICE), dollar(20) - fee * 2);
});
}

0 comments on commit 8288c94

Please sign in to comment.