git.delta.rocks / unique-network / refs/commits / 6a055472d116

difftreelog

Tests: unstakeAll after each test

Max Andreev2023-02-15parent: #5495238.patch.diff
in: master

2 files changed

modifiedtests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth
26let nominal: bigint;26let nominal: bigint;
27let palletAddress: string;27let palletAddress: string;
28let accounts: IKeyringPair[];28let accounts: IKeyringPair[];
29let usedAccounts: IKeyringPair[] = [];
30
31function getAccount(accountsNumber: number) {
32 const accs = accounts.splice(0, accountsNumber);
33 usedAccounts.push(...accs);
34 return accs;
35}
29// App promotion periods:36// App promotion periods:
30// LOCKING_PERIOD = 12 blocks of relay37// LOCKING_PERIOD = 12 blocks of relay
31// UNLOCKING_PERIOD = 6 blocks of parachain38// UNLOCKING_PERIOD = 6 blocks of parachain
39 palletAdmin = await privateKey('//PromotionAdmin');46 palletAdmin = await privateKey('//PromotionAdmin');
40 nominal = helper.balance.getOneTokenNominal();47 nominal = helper.balance.getOneTokenNominal();
4148
42 const accountBalances = new Array(100);49 const accountBalances = new Array(200).fill(1000n);
43 accountBalances.fill(1000n);
44 accounts = await helper.arrange.createAccounts(accountBalances, donor); // create accounts-pool to speed up tests50 accounts = await helper.arrange.createAccounts(accountBalances, donor); // create accounts-pool to speed up tests
51 });
52 });
53
54 afterEach(async () => {
55 await usingPlaygrounds(async (helper) => {
56 let unstakeTxs = [];
57 for (const account of usedAccounts) {
58 if (unstakeTxs.length === 3) {
59 await Promise.all(unstakeTxs);
60 unstakeTxs = [];
61 }
62 unstakeTxs.push(helper.staking.unstakeAll(account));
63 }
64 await Promise.all(unstakeTxs);
65 usedAccounts = [];
45 });66 });
46 });67 });
4768
48 describe('stake extrinsic', () => {69 describe('stake extrinsic', () => {
49 itSub('should "lock" staking balance, add it to "staked" map, and increase "totalStaked" amount', async ({helper}) => {70 itSub('should "lock" staking balance, add it to "staked" map, and increase "totalStaked" amount', async ({helper}) => {
50 const [staker, recepient] = [accounts.pop()!, accounts.pop()!];71 const [staker, recepient] = getAccount(2);
51 const totalStakedBefore = await helper.staking.getTotalStaked();72 const totalStakedBefore = await helper.staking.getTotalStaked();
5273
53 // Minimum stake amount is 100:74 // Minimum stake amount is 100:
114 });135 });
115136
116 itSub('should allow to stake() if balance is locked with different id', async ({helper}) => {137 itSub('should allow to stake() if balance is locked with different id', async ({helper}) => {
117 const staker = accounts.pop()!;138 const [staker] = getAccount(1);
118139
119 // staker has tokens locked with vesting id:140 // staker has tokens locked with vesting id:
120 await helper.balance.vestedTransfer(donor, staker.address, {start: 0n, period: 1n, periodCount: 1n, perPeriod: 200n * nominal});141 await helper.balance.vestedTransfer(donor, staker.address, {start: 0n, period: 1n, periodCount: 1n, perPeriod: 200n * nominal});
147 });168 });
148169
149 itSub('should not allow to stake(), if stake amount is more than total free balance minus locked by staking', async ({helper}) => {170 itSub('should not allow to stake(), if stake amount is more than total free balance minus locked by staking', async ({helper}) => {
150 const staker = accounts.pop()!;171 const [staker] = getAccount(1);
151172
152 // Can't stake full balance because Alice needs to pay some fee173 // Can't stake full balance because Alice needs to pay some fee
153 await expect(helper.staking.stake(staker, 1000n * nominal)).to.be.rejected; // With('Arithmetic')174 await expect(helper.staking.stake(staker, 1000n * nominal)).to.be.rejected; // With('Arithmetic')
159 });180 });
160181
161 itSub('for different accounts in one block is possible', async ({helper}) => {182 itSub('for different accounts in one block is possible', async ({helper}) => {
162 const crowd = [accounts.pop()!, accounts.pop()!, accounts.pop()!, accounts.pop()!];183 const crowd = getAccount(4);
163184
164 const crowdStartsToStake = crowd.map(user => helper.staking.stake(user, 100n * nominal));185 const crowdStartsToStake = crowd.map(user => helper.staking.stake(user, 100n * nominal));
165 await expect(Promise.all(crowdStartsToStake)).to.be.fulfilled;186 await expect(Promise.all(crowdStartsToStake)).to.be.fulfilled;
175 {method: 'unstakePartial' as const},196 {method: 'unstakePartial' as const},
176 ].map(testCase => {197 ].map(testCase => {
177 itSub(`[${testCase.method}] should move tokens to "pendingUnstake" and subtract it from totalStaked`, async ({helper}) => {198 itSub(`[${testCase.method}] should move tokens to "pendingUnstake" and subtract it from totalStaked`, async ({helper}) => {
178 const [staker, recepient] = [accounts.pop()!, accounts.pop()!];199 const [staker, recepient] = getAccount(2);
179 const totalStakedBefore = await helper.staking.getTotalStaked();200 const totalStakedBefore = await helper.staking.getTotalStaked();
180 const STAKE_AMOUNT = 900n * nominal;201 const STAKE_AMOUNT = 900n * nominal;
181202
201 {method: 'unstakePartial' as const},222 {method: 'unstakePartial' as const},
202 ].map(testCase => {223 ].map(testCase => {
203 itSub(`[${testCase.method}] should unlock balance after unlocking period ends and remove it from "pendingUnstake"`, async ({helper}) => {224 itSub(`[${testCase.method}] should unlock balance after unlocking period ends and remove it from "pendingUnstake"`, async ({helper}) => {
204 const staker = accounts.pop()!;225 const [staker] = getAccount(1);
205 await helper.staking.stake(staker, 100n * nominal);226 await helper.staking.stake(staker, 100n * nominal);
206 testCase.method === 'unstakeAll'227 testCase.method === 'unstakeAll'
207 ? await helper.staking.unstakeAll(staker)228 ? await helper.staking.unstakeAll(staker)
224 {method: 'unstakePartial' as const},245 {method: 'unstakePartial' as const},
225 ].map(testCase => {246 ].map(testCase => {
226 itSub(`[${testCase.method}] should successfully unstake multiple stakes`, async ({helper}) => {247 itSub(`[${testCase.method}] should successfully unstake multiple stakes`, async ({helper}) => {
227 const staker = accounts.pop()!;248 const [staker] = getAccount(1);
228 await helper.staking.stake(staker, 100n * nominal);249 await helper.staking.stake(staker, 100n * nominal);
229 await helper.staking.stake(staker, 200n * nominal);250 await helper.staking.stake(staker, 200n * nominal);
230 await helper.staking.stake(staker, 300n * nominal);251 await helper.staking.stake(staker, 300n * nominal);
264 {method: 'unstakePartial' as const},285 {method: 'unstakePartial' as const},
265 ].map(testCase => {286 ].map(testCase => {
266 itSub(`[${testCase.method}] should not have any effects if no active stakes`, async ({helper}) => {287 itSub(`[${testCase.method}] should not have any effects if no active stakes`, async ({helper}) => {
267 const staker = accounts.pop()!;288 const [staker] = getAccount(1);
268289
269 // unstake has no effect if no stakes at all290 // unstake has no effect if no stakes at all
270 testCase.method === 'unstakeAll'291 testCase.method === 'unstakeAll'
298 {method: 'unstakePartial' as const},319 {method: 'unstakePartial' as const},
299 ].map(testCase => {320 ].map(testCase => {
300 itSub(`[${testCase.method}] should create different pending-unlock for each unlocking stake`, async ({helper}) => {321 itSub(`[${testCase.method}] should create different pending-unlock for each unlocking stake`, async ({helper}) => {
301 const staker = accounts.pop()!;322 const [staker] = getAccount(1);
302 await helper.staking.stake(staker, 100n * nominal);323 await helper.staking.stake(staker, 100n * nominal);
303 testCase.method === 'unstakeAll'324 testCase.method === 'unstakeAll'
304 ? await helper.staking.unstakeAll(staker)325 ? await helper.staking.unstakeAll(staker)
321 {method: 'unstakePartial' as const},342 {method: 'unstakePartial' as const},
322 ].map(testCase => {343 ].map(testCase => {
323 itSub(`[${testCase.method}] should be possible for 3 accounts in one block`, async ({helper}) => {344 itSub(`[${testCase.method}] should be possible for 3 accounts in one block`, async ({helper}) => {
324 const stakers = [accounts.pop()!, accounts.pop()!, accounts.pop()!];345 const stakers = getAccount(3);
325346
326 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));347 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
327 await Promise.all(stakers.map(staker => {348 await Promise.all(stakers.map(staker => {
339360
340 itSub('should not be possible for more than 3 accounts in one block', async ({helper}) => {361 itSub('should not be possible for more than 3 accounts in one block', async ({helper}) => {
341 if (!await helper.arrange.isDevNode()) {362 if (!await helper.arrange.isDevNode()) {
342 const stakers = await helper.arrange.createAccounts([200n,200n,200n,200n,200n,200n,200n,200n,200n,200n], donor);363 const stakers = getAccount(10);
343364
344 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));365 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
345 const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => {366 const unstakingResults = await Promise.allSettled(stakers.map((staker, i) => {
354 });375 });
355376
356 itSub('Cannot partially unstake more than staked', async ({helper}) => {377 itSub('Cannot partially unstake more than staked', async ({helper}) => {
357 const staker = accounts.pop()!;378 const [staker] = getAccount(1);
358 // Staker stakes 300:379 // Staker stakes 300:
359 await helper.staking.stake(staker, 100n * nominal);380 await helper.staking.stake(staker, 100n * nominal);
360 await helper.staking.stake(staker, 200n * nominal);381 await helper.staking.stake(staker, 200n * nominal);
374 });395 });
375396
376 itSub('Can partially unstake arbitrary amount', async ({helper}) => {397 itSub('Can partially unstake arbitrary amount', async ({helper}) => {
377 const staker = accounts.pop()!;398 const [staker] = getAccount(1);
378 await helper.staking.stake(staker, 100n * nominal);399 await helper.staking.stake(staker, 100n * nominal);
379 await helper.staking.stake(staker, 200n * nominal);400 await helper.staking.stake(staker, 200n * nominal);
380401
408 });429 });
409430
410 itSub('can mix different type of unstakes', async ({helper}) => {431 itSub('can mix different type of unstakes', async ({helper}) => {
411 const staker = accounts.pop()!;432 const [staker] = getAccount(1);
412 await helper.staking.stake(staker, 100n * nominal);433 await helper.staking.stake(staker, 100n * nominal);
413 await helper.staking.stake(staker, 200n * nominal);434 await helper.staking.stake(staker, 200n * nominal);
414435
433 describe('collection sponsoring', () => {454 describe('collection sponsoring', () => {
434 itSub('should actually sponsor transactions', async ({helper}) => {455 itSub('should actually sponsor transactions', async ({helper}) => {
435 const api = helper.getApi();456 const api = helper.getApi();
436 const [collectionOwner, tokenSender, receiver] = [accounts.pop()!, accounts.pop()!, accounts.pop()!];457 const [collectionOwner, tokenSender, receiver] = getAccount(3);
437 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'Name', description: 'Description', tokenPrefix: 'Prefix', limits: {sponsorTransferTimeout: 0}});458 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'Name', description: 'Description', tokenPrefix: 'Prefix', limits: {sponsorTransferTimeout: 0}});
438 const token = await collection.mintToken(collectionOwner, {Substrate: tokenSender.address});459 const token = await collection.mintToken(collectionOwner, {Substrate: tokenSender.address});
439 await helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId));460 await helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId));
450471
451 itSub('can not be set by non admin', async ({helper}) => {472 itSub('can not be set by non admin', async ({helper}) => {
452 const api = helper.getApi();473 const api = helper.getApi();
453 const [collectionOwner, nonAdmin] = [accounts.pop()!, accounts.pop()!];474 const [collectionOwner, nonAdmin] = getAccount(2);
454475
455 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});476 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});
456477
460481
461 itSub('should set pallet address as confirmed admin', async ({helper}) => {482 itSub('should set pallet address as confirmed admin', async ({helper}) => {
462 const api = helper.getApi();483 const api = helper.getApi();
463 const [collectionOwner, oldSponsor] = [accounts.pop()!, accounts.pop()!];484 const [collectionOwner, oldSponsor] = getAccount(2);
464485
465 // Can set sponsoring for collection without sponsor486 // Can set sponsoring for collection without sponsor
466 const collectionWithoutSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'No-sponsor', description: 'New Collection', tokenPrefix: 'Promotion'});487 const collectionWithoutSponsor = await helper.nft.mintCollection(collectionOwner, {name: 'No-sponsor', description: 'New Collection', tokenPrefix: 'Promotion'});
482503
483 itSub('can be overwritten by collection owner', async ({helper}) => {504 itSub('can be overwritten by collection owner', async ({helper}) => {
484 const api = helper.getApi();505 const api = helper.getApi();
485 const [collectionOwner, newSponsor] = [accounts.pop()!, accounts.pop()!];506 const [collectionOwner, newSponsor] = getAccount(2);
486 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});507 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});
487 const collectionId = collection.collectionId;508 const collectionId = collection.collectionId;
488509
501 itSub('should not overwrite collection limits set by the owner earlier', async ({helper}) => {522 itSub('should not overwrite collection limits set by the owner earlier', async ({helper}) => {
502 const api = helper.getApi();523 const api = helper.getApi();
503 const limits = {ownerCanDestroy: true, ownerCanTransfer: true, sponsorTransferTimeout: 0};524 const limits = {ownerCanDestroy: true, ownerCanTransfer: true, sponsorTransferTimeout: 0};
504 const collectionWithLimits = await helper.nft.mintCollection(accounts.pop()!, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits});525 const collectionWithLimits = await helper.nft.mintCollection(getAccount(1)[0], {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits});
505526
506 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionWithLimits.collectionId))).to.be.fulfilled;527 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collectionWithLimits.collectionId))).to.be.fulfilled;
507 expect((await collectionWithLimits.getData())?.raw.limits).to.be.deep.contain(limits);528 expect((await collectionWithLimits.getData())?.raw.limits).to.be.deep.contain(limits);
508 });529 });
509530
510 itSub('should reject transaction if collection doesn\'t exist', async ({helper}) => {531 itSub('should reject transaction if collection doesn\'t exist', async ({helper}) => {
511 const api = helper.getApi();532 const api = helper.getApi();
512 const collectionOwner = accounts.pop()!;533 const [collectionOwner] = getAccount(1);
513534
514 // collection has never existed535 // collection has never existed
515 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(999999999))).to.be.rejected;536 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(999999999))).to.be.rejected;
524 describe('stopSponsoringCollection', () => {545 describe('stopSponsoringCollection', () => {
525 itSub('can not be called by non-admin', async ({helper}) => {546 itSub('can not be called by non-admin', async ({helper}) => {
526 const api = helper.getApi();547 const api = helper.getApi();
527 const [collectionOwner, nonAdmin] = [accounts.pop()!, accounts.pop()!];548 const [collectionOwner, nonAdmin] = getAccount(2);
528 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});549 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});
529550
530 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;551 await expect(helper.signTransaction(palletAdmin, api.tx.appPromotion.sponsorCollection(collection.collectionId))).to.be.fulfilled;
535556
536 itSub('should set sponsoring as disabled', async ({helper}) => {557 itSub('should set sponsoring as disabled', async ({helper}) => {
537 const api = helper.getApi();558 const api = helper.getApi();
538 const [collectionOwner, recepient] = [accounts.pop()!, accounts.pop()!];559 const [collectionOwner, recepient] = getAccount(2);
539 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits: {sponsorTransferTimeout: 0}});560 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', limits: {sponsorTransferTimeout: 0}});
540 const token = await collection.mintToken(collectionOwner, {Substrate: collectionOwner.address});561 const token = await collection.mintToken(collectionOwner, {Substrate: collectionOwner.address});
541562
553574
554 itSub('should not affect collection which is not sponsored by pallete', async ({helper}) => {575 itSub('should not affect collection which is not sponsored by pallete', async ({helper}) => {
555 const api = helper.getApi();576 const api = helper.getApi();
556 const collectionOwner = accounts.pop()!;577 const [collectionOwner] = getAccount(1);
557 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: collectionOwner.address});578 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion', pendingSponsor: collectionOwner.address});
558 await collection.confirmSponsorship(collectionOwner);579 await collection.confirmSponsorship(collectionOwner);
559580
563 });584 });
564585
565 itSub('should reject transaction if collection does not exist', async ({helper}) => {586 itSub('should reject transaction if collection does not exist', async ({helper}) => {
566 const collectionOwner = accounts.pop()!;587 const [collectionOwner] = getAccount(1);
567 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});588 const collection = await helper.nft.mintCollection(collectionOwner, {name: 'New', description: 'New Collection', tokenPrefix: 'Promotion'});
568589
569 await collection.burn(collectionOwner);590 await collection.burn(collectionOwner);
637 });658 });
638659
639 itEth('can not be set by non admin', async ({helper}) => {660 itEth('can not be set by non admin', async ({helper}) => {
640 const nonAdmin = accounts.pop()!;661 const [nonAdmin] = getAccount(1);
641 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();662 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();
642 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);663 const flipper = await helper.eth.deployFlipper(contractOwner); // await deployFlipper(web3, contractOwner);
643 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);664 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);
719 });740 });
720741
721 itEth('can not be called by non-admin', async ({helper}) => {742 itEth('can not be called by non-admin', async ({helper}) => {
722 const nonAdmin = accounts.pop()!;743 const [nonAdmin] = getAccount(1);
723 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();744 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();
724 const flipper = await helper.eth.deployFlipper(contractOwner);745 const flipper = await helper.eth.deployFlipper(contractOwner);
725746
729 });750 });
730751
731 itEth('should not affect a contract which is not sponsored by pallete', async ({helper}) => {752 itEth('should not affect a contract which is not sponsored by pallete', async ({helper}) => {
732 const nonAdmin = accounts.pop()!;753 const [nonAdmin] = getAccount(1);
733 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();754 const contractOwner = (await helper.eth.createAccountWithBalance(donor, 1000n)).toLowerCase();
734 const flipper = await helper.eth.deployFlipper(contractOwner);755 const flipper = await helper.eth.deployFlipper(contractOwner);
735 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);756 const contractHelper = await helper.ethNativeContract.contractHelpers(contractOwner);
741762
742 describe('payoutStakers', () => {763 describe('payoutStakers', () => {
743 itSub('can not be called by non admin', async ({helper}) => {764 itSub('can not be called by non admin', async ({helper}) => {
744 const nonAdmin = accounts.pop()!;765 const [nonAdmin] = getAccount(1);
745 await expect(helper.admin.payoutStakers(nonAdmin, 100)).to.be.rejectedWith('appPromotion.NoPermission');766 await expect(helper.admin.payoutStakers(nonAdmin, 100)).to.be.rejectedWith('appPromotion.NoPermission');
746 });767 });
747768
748 itSub('should increase total staked', async ({helper}) => {769 itSub('should increase total staked', async ({helper}) => {
749 const staker = accounts.pop()!;770 const [staker] = getAccount(1);
750 const totalStakedBefore = await helper.staking.getTotalStaked();771 const totalStakedBefore = await helper.staking.getTotalStaked();
751 await helper.staking.stake(staker, 100n * nominal);772 await helper.staking.stake(staker, 100n * nominal);
752773
763 });784 });
764785
765 itSub('should credit 0.05% for staking period', async ({helper}) => {786 itSub('should credit 0.05% for staking period', async ({helper}) => {
766 const staker = accounts.pop()!;787 const [staker] = getAccount(1);
767788
768 await waitPromotionPeriodDoesntEnd(helper);789 await waitPromotionPeriodDoesntEnd(helper);
769790
789 });810 });
790811
791 itSub('shoud be paid for more than one period if payments was missed', async ({helper}) => {812 itSub('shoud be paid for more than one period if payments was missed', async ({helper}) => {
792 const staker = accounts.pop()!;813 const [staker] = getAccount(1);
793814
794 await helper.staking.stake(staker, 100n * nominal);815 await helper.staking.stake(staker, 100n * nominal);
795 // wait for two rewards are available:816 // wait for two rewards are available:
808829
809 itSub('should not be credited for pending-unstaked tokens', async ({helper}) => {830 itSub('should not be credited for pending-unstaked tokens', async ({helper}) => {
810 // staker unstakes before rewards been payed831 // staker unstakes before rewards been payed
811 const staker = accounts.pop()!;832 const [staker] = getAccount(1);
812 await helper.staking.stake(staker, 100n * nominal);833 await helper.staking.stake(staker, 100n * nominal);
813 const [stake] = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});834 const [stake] = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});
814 await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stake.block) + LOCKING_PERIOD);835 await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stake.block) + LOCKING_PERIOD);
823 });844 });
824845
825 itSub('should bring compound interest', async ({helper}) => {846 itSub('should bring compound interest', async ({helper}) => {
826 const staker = accounts.pop()!;847 const [staker] = getAccount(1);
827848
828 await helper.staking.stake(staker, 100n * nominal);849 await helper.staking.stake(staker, 100n * nominal);
829850
841 });862 });
842863
843 itSub('can calculate reward for tiny stake', async ({helper}) => {864 itSub('can calculate reward for tiny stake', async ({helper}) => {
844 const staker = accounts.pop()!;865 const [staker] = getAccount(1);
845 await helper.staking.stake(staker, 100n * nominal);866 await helper.staking.stake(staker, 100n * nominal);
846 await helper.staking.stake(staker, 100n * nominal);867 await helper.staking.stake(staker, 100n * nominal);
847 await helper.staking.unstakePartial(staker, 100n * nominal - 1n);868 await helper.staking.unstakePartial(staker, 100n * nominal - 1n);
855 });876 });
856877
857 itSub('can eventually pay all rewards', async ({helper}) => {878 itSub('can eventually pay all rewards', async ({helper}) => {
858 const stakers = await helper.arrange.createAccounts(new Array(100).fill(200n), donor);879 const stakers = getAccount(30);
880 // Create 30 stakes:
859 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));881 await Promise.all(stakers.map(staker => helper.staking.stake(staker, 100n * nominal)));
860882
861 let unstakingTxs = [];883 let unstakingTxs = [];
867 unstakingTxs.push(helper.staking.unstakePartial(staker, 100n * nominal - 1n));889 unstakingTxs.push(helper.staking.unstakePartial(staker, 100n * nominal - 1n));
868 }890 }
869891
870 const [staker] = await helper.arrange.createAccounts([1000n], donor);892 const [staker] = getAccount(1);
871 await helper.staking.stake(staker, 100n * nominal);893 await helper.staking.stake(staker, 100n * nominal);
872 const [stake] = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});894 const [stake] = await helper.staking.getTotalStakedPerBlock({Substrate: staker.address});
873 await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stake.block));895 await helper.wait.forRelayBlockNumber(rewardAvailableInBlock(stake.block));
modifiedtests/src/util/globalSetup.tsdiffbeforeafterboth
--- a/tests/src/util/globalSetup.ts
+++ b/tests/src/util/globalSetup.ts
@@ -29,8 +29,8 @@
         const api = helper.getApi();
         await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));
         const nominal = helper.balance.getOneTokenNominal();
-        await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 1000n * nominal);
-        await helper.balance.transferToSubstrate(superuser, palletAddress, 1000n * nominal);
+        await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 10000n * nominal);
+        await helper.balance.transferToSubstrate(superuser, palletAddress, 10000n * nominal);
         await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.configuration
           .setAppPromotionConfigurationOverride({
             recalculationInterval: LOCKING_PERIOD,