Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed May 28, 2024
1 parent 9b05ffc commit 7520861
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pallets/dapp-staking-v3/src/test/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3044,14 +3044,19 @@ fn base_number_of_slots_is_respected() {
let base_thresholds = TierConfig::<Test>::get().tier_thresholds;

// 2. Increase the price significantly, and ensure number of slots has increased, and thresholds have been saturated.
NATIVE_PRICE.with(|v| *v.borrow_mut() = base_native_price * FixedU128::from(1000));
let higher_price = base_native_price * FixedU128::from(1000);
NATIVE_PRICE.with(|v| *v.borrow_mut() = higher_price);
assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era));
run_for_blocks(1);

assert!(
TierConfig::<Test>::get().number_of_slots > base_number_of_slots,
"Price has increased, therefore number of slots must increase."
);
assert_eq!(
TierConfig::<Test>::get().number_of_slots,
<Test as Config>::TierSlots::number_of_slots(higher_price),
);

for tier_threshold in TierConfig::<Test>::get().tier_thresholds.iter() {
if let TierThreshold::DynamicTvlAmount {
Expand Down Expand Up @@ -3082,15 +3087,19 @@ fn base_number_of_slots_is_respected() {
);

// 4. Bring it below the base price, and expect number of slots to decrease.
NATIVE_PRICE
.with(|v| *v.borrow_mut() = base_native_price * FixedU128::from_rational(1, 1000));
let lower_price = base_native_price * FixedU128::from_rational(1, 1000);
NATIVE_PRICE.with(|v| *v.borrow_mut() = lower_price);
assert_ok!(DappStaking::force(RuntimeOrigin::root(), ForcingType::Era));
run_for_blocks(1);

assert!(
TierConfig::<Test>::get().number_of_slots < base_number_of_slots,
"Price has decreased, therefore number of slots must decrease."
);
assert_eq!(
TierConfig::<Test>::get().number_of_slots,
<Test as Config>::TierSlots::number_of_slots(lower_price),
);

// 5. Bring it back to the base price, and expect number of slots to be the same as the base number of slots,
// and thresholds to be the same as the base thresholds.
Expand Down

0 comments on commit 7520861

Please sign in to comment.