git.delta.rocks / unique-network / refs/commits / 4acc79c47525

difftreelog

Make previousCalculatedRecord eq None before tests

Max Andreev2023-04-11parent: #69f287a.patch.diff
in: master

1 file changed

modifiedtests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth
71 await Promise.all(unstakeTxs);71 await Promise.all(unstakeTxs);
72 usedAccounts = [];72 usedAccounts = [];
73 expect(await helper.staking.getTotalStaked()).to.eq(0n); // there are no active stakes after each test73 expect(await helper.staking.getTotalStaked()).to.eq(0n); // there are no active stakes after each test
74 // Make sure previousCalculatedRecord is None to avoid problem with payout stakers;
75 await helper.admin.payoutStakers(palletAdmin, 100);
76 expect((await helper.getApi().query.appPromotion.previousCalculatedRecord() as any).isNone).to.be.true;
74 });77 });
75 });78 });
7679
784 const [stakedInBlock] = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});787 const [stakedInBlock] = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});
785 await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stakedInBlock.block));788 await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stakedInBlock.block));
789
790 const payout = await helper.admin.payoutStakers(palletAdmin, 100);
786 const totalPayout = (await helper.admin.payoutStakers(palletAdmin, 100)).reduce((prev, payout) => prev + payout.payout, 0n);791 const totalPayout = payout.reduce((prev, payout) => prev + payout.payout, 0n);
792 const stakerReward = payout.find(p => p.staker === staker.address);
793
794 expect(stakerReward?.payout).to.eq(calculateIncome(100n * nominal) - (100n * nominal));
787795
788 const totalStakedAfter = await helper.staking.getTotalStaked();796 const totalStakedAfter = await helper.staking.getTotalStaked();
789 expect(totalStakedAfter).to.equal(totalStakedBefore + (100n * nominal) + totalPayout);797 expect(totalStakedAfter).to.equal(totalStakedBefore + (100n * nominal) + totalPayout);