git.delta.rocks / unique-network / refs/commits / d11ad96fff69

difftreelog

Merge branch 'feature/app-staking' of github.com:UniqueNetwork/unique-chain into feature/app-staking

Trubnikov Sergey2022-09-01parents: #081dbb6 #f8428bb.patch.diff
in: master

2 files changed

modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
328 ArithmeticError::Underflow328 ArithmeticError::Underflow
329 );329 );
330
331 let count = Staked::<T>::iter_prefix((staker_id.clone(),)).count();
332330
333 let balance =331 let balance =
334 <<T as Config>::Currency as Currency<T::AccountId>>::free_balance(&staker_id);332 <<T as Config>::Currency as Currency<T::AccountId>>::free_balance(&staker_id);
521 income_acc = BalanceOf::<T>::default();519 income_acc = BalanceOf::<T>::default();
522 current_id = id;520 current_id = id;
523 };521 };
524 if next_recalc_block_for_stake >= current_recalc_block {522 if current_recalc_block >= next_recalc_block_for_stake {
525 Self::recalculate_and_insert_stake(523 Self::recalculate_and_insert_stake(
526 &current_id,524 &current_id,
527 staked_block,525 staked_block,
528 next_recalc_block,526 next_recalc_block,
529 amount,527 amount,
530 ((next_recalc_block_for_stake - current_recalc_block)528 ((current_recalc_block - next_recalc_block_for_stake)
531 / T::RecalculationInterval::get())529 / T::RecalculationInterval::get())
532 .into() + 1,530 .into() + 1,
533 &mut income_acc,531 &mut income_acc,
modifiedtests/src/app-promotion.test.tsdiffbeforeafterboth
--- a/tests/src/app-promotion.test.ts
+++ b/tests/src/app-promotion.test.ts
@@ -621,7 +621,7 @@
       
       await helper.staking.stake(staker, 100n * nominal);
       await helper.staking.stake(staker, 200n * nominal);
-      await waitForRelayBlock(helper.api!, 55);
+      await waitForRelayBlock(helper.api!, 40);
       await helper.signTransaction(palletAdmin, helper.api!.tx.promotion.payoutStakers(50));
       
       const totalStakedPerBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address})).map(s => s[1]);
@@ -663,7 +663,7 @@
       await waitForRelayBlock(helper.api!, 20);
       await helper.signTransaction(palletAdmin, helper.api!.tx.promotion.payoutStakers(50));
       totalStakedPerBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address})).map(s => s[1]);
-      expect(totalStakedPerBlock).to.deep.equal([calculateIncome(10n * nominal, 10n, 2), calculateIncome(20n * nominal, 10n, 2), calculateIncome(30n * nominal, 10n, 2)]);      
+      expect(totalStakedPerBlock).to.deep.equal([calculateIncome(100n * nominal, 10n, 2), calculateIncome(200n * nominal, 10n, 2), calculateIncome(300n * nominal, 10n, 2)]);      
     });
   });