difftreelog
Merge branch 'feature/app-staking' of github.com:UniqueNetwork/unique-chain into feature/app-staking
in: master
2 files changed
pallets/app-promotion/src/lib.rsdiffbeforeafterboth328 ArithmeticError::Underflow328 ArithmeticError::Underflow329 );329 );330331 let count = Staked::<T>::iter_prefix((staker_id.clone(),)).count();332330333 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 ¤t_id,524 ¤t_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,tests/src/app-promotion.test.tsdiffbeforeafterboth621 621 622 await helper.staking.stake(staker, 100n * nominal);622 await helper.staking.stake(staker, 100n * nominal);623 await helper.staking.stake(staker, 200n * nominal);623 await helper.staking.stake(staker, 200n * nominal);624 await waitForRelayBlock(helper.api!, 55);624 await waitForRelayBlock(helper.api!, 40);625 await helper.signTransaction(palletAdmin, helper.api!.tx.promotion.payoutStakers(50));625 await helper.signTransaction(palletAdmin, helper.api!.tx.promotion.payoutStakers(50));626 626 627 const totalStakedPerBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address})).map(s => s[1]);627 const totalStakedPerBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address})).map(s => s[1]);663 await waitForRelayBlock(helper.api!, 20);663 await waitForRelayBlock(helper.api!, 20);664 await helper.signTransaction(palletAdmin, helper.api!.tx.promotion.payoutStakers(50));664 await helper.signTransaction(palletAdmin, helper.api!.tx.promotion.payoutStakers(50));665 totalStakedPerBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address})).map(s => s[1]);665 totalStakedPerBlock = (await helper.staking.getTotalStakedPerBlock({Substrate: staker.address})).map(s => s[1]);666 expect(totalStakedPerBlock).to.deep.equal([calculateIncome(10n * nominal, 10n, 2), calculateIncome(20n * nominal, 10n, 2), calculateIncome(30n * nominal, 10n, 2)]); 666 expect(totalStakedPerBlock).to.deep.equal([calculateIncome(100n * nominal, 10n, 2), calculateIncome(200n * nominal, 10n, 2), calculateIncome(300n * nominal, 10n, 2)]); 667 });667 });668 });668 });669669