difftreelog
Tests: unstakeAll after each test
in: master
2 files changed
tests/src/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth26let nominal: bigint;26let nominal: bigint;27let palletAddress: string;27let palletAddress: string;28let accounts: IKeyringPair[];28let accounts: IKeyringPair[];29let usedAccounts: IKeyringPair[] = [];3031function 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 relay31// UNLOCKING_PERIOD = 6 blocks of parachain38// UNLOCKING_PERIOD = 6 blocks of parachain39 palletAdmin = await privateKey('//PromotionAdmin');46 palletAdmin = await privateKey('//PromotionAdmin');40 nominal = helper.balance.getOneTokenNominal();47 nominal = helper.balance.getOneTokenNominal();414842 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 tests51 });52 });5354 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 });476848 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();527353 // Minimum stake amount is 100:74 // Minimum stake amount is 100:114 });135 });115136116 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);118139119 // 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 });148169149 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);151172152 // Can't stake full balance because Alice needs to pay some fee173 // Can't stake full balance because Alice needs to pay some fee153 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 });160181161 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);163184164 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;181202201 {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);268289269 // unstake has no effect if no stakes at all290 // unstake has no effect if no stakes at all270 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);325346326 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 => {339360340 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);343364344 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 });355376356 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 });375396376 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);380401408 });429 });409430410 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);414435433 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));450471451 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);454475455 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'});456477460481461 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);464485465 // Can set sponsoring for collection without sponsor486 // Can set sponsoring for collection without sponsor466 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'});482503483 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;488509501 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});505526506 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 });509530510 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);513534514 // collection has never existed535 // collection has never existed515 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'});529550530 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;535556536 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});541562553574554 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);559580563 });584 });564585565 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'});568589569 await collection.burn(collectionOwner);590 await collection.burn(collectionOwner);637 });658 });638659639 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 });720741721 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);725746729 });750 });730751731 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);741762742 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 });747768748 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);752773763 });784 });764785765 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);767788768 await waitPromotionPeriodDoesntEnd(helper);789 await waitPromotionPeriodDoesntEnd(helper);769790789 });810 });790811791 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);793814794 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:808829809 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 payed811 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 });824845825 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);827848828 await helper.staking.stake(staker, 100n * nominal);849 await helper.staking.stake(staker, 100n * nominal);829850841 });862 });842863843 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 });856877857 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)));860882861 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 }869891870 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));tests/src/util/globalSetup.tsdiffbeforeafterboth29 const api = helper.getApi();29 const api = helper.getApi();30 await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));30 await helper.signTransaction(superuser, api.tx.sudo.sudo(api.tx.appPromotion.setAdminAddress({Substrate: palletAdmin.address})));31 const nominal = helper.balance.getOneTokenNominal();31 const nominal = helper.balance.getOneTokenNominal();32 await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 1000n * nominal);32 await helper.balance.transferToSubstrate(superuser, palletAdmin.address, 10000n * nominal);33 await helper.balance.transferToSubstrate(superuser, palletAddress, 1000n * nominal);33 await helper.balance.transferToSubstrate(superuser, palletAddress, 10000n * nominal);34 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.configuration34 await helper.executeExtrinsic(superuser, 'api.tx.sudo.sudo', [api.tx.configuration35 .setAppPromotionConfigurationOverride({35 .setAppPromotionConfigurationOverride({36 recalculationInterval: LOCKING_PERIOD,36 recalculationInterval: LOCKING_PERIOD,