difftreelog
tests(scheduler): exclude from parallel execution + adapt accounts
in: master
1 file changed
tests/src/scheduler.seqtest.tsdiffbeforeafterboth19import {DevUniqueHelper} from './util/playgrounds/unique.dev';19import {DevUniqueHelper} from './util/playgrounds/unique.dev';202021describe('Scheduling token and balance transfers', () => {21describe('Scheduling token and balance transfers', () => {22 let superuser: IKeyringPair;22 let alice: IKeyringPair;23 let alice: IKeyringPair;23 let bob: IKeyringPair;24 let bob: IKeyringPair;24 let charlie: IKeyringPair;25 let charlie: IKeyringPair;252626 before(async function() {27 before(async function() {27 await usingPlaygrounds(async (helper, privateKeyWrapper) => {28 await usingPlaygrounds(async (helper, privateKey) => {29 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);3028 alice = await privateKeyWrapper('//Alice');31 superuser = await privateKey('//Alice');29 bob = await privateKeyWrapper('//Bob');32 const donor = await privateKey({filename: __filename});30 charlie = await privateKeyWrapper('//Charlie');33 [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);3132 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);333434 await helper.testUtils.enable();35 await helper.testUtils.enable();35 });36 });308 await token.scheduleAfter(scheduledId, waitForBlocks)309 await token.scheduleAfter(scheduledId, waitForBlocks)309 .transfer(bob, {Substrate: alice.address});310 .transfer(bob, {Substrate: alice.address});310311311 await helper.getSudo().scheduler.cancelScheduled(alice, scheduledId);312 await helper.getSudo().scheduler.cancelScheduled(superuser, scheduledId);312313313 await helper.wait.newBlocks(waitForBlocks + 1);314 await helper.wait.newBlocks(waitForBlocks + 1);314315325326326 await helper.getSudo()327 await helper.getSudo()327 .scheduler.scheduleAfter(scheduledId, waitForBlocks, {priority: 42})328 .scheduler.scheduleAfter(scheduledId, waitForBlocks, {priority: 42})328 .balance.forceTransferToSubstrate(alice, bob.address, charlie.address, amount);329 .balance.forceTransferToSubstrate(superuser, bob.address, charlie.address, amount);329330330 await helper.wait.newBlocks(waitForBlocks + 1);331 await helper.wait.newBlocks(waitForBlocks + 1);331332348 .transfer(bob, {Substrate: alice.address});349 .transfer(bob, {Substrate: alice.address});349350350 const priority = 112;351 const priority = 112;351 await helper.getSudo().scheduler.changePriority(alice, scheduledId, priority);352 await helper.getSudo().scheduler.changePriority(superuser, scheduledId, priority);352353353 const priorityChanged = await helper.wait.event(354 const priorityChanged = await helper.wait.event(354 waitForBlocks,355 waitForBlocks,360 expect(priorityChanged!.event.data[2].toString()).to.be.equal(priority.toString());361 expect(priorityChanged!.event.data[2].toString()).to.be.equal(priority.toString());361 });362 });362363363 itSub('Prioritized operations executes in valid order', async ({helper}) => {364 itSub('Prioritized operations execute in valid order', async ({helper}) => {364 const [365 const [365 scheduledFirstId,366 scheduledFirstId,366 scheduledSecondId,367 scheduledSecondId,382383383 // Scheduler a task with a lower priority first, then with a higher priority384 // Scheduler a task with a lower priority first, then with a higher priority384 await helper.getSudo().scheduler.scheduleAt(scheduledFirstId, firstExecutionBlockNumber, {priority: prioLow, periodic})385 await helper.getSudo().scheduler.scheduleAt(scheduledFirstId, firstExecutionBlockNumber, {priority: prioLow, periodic})385 .balance.forceTransferToSubstrate(alice, alice.address, bob.address, amount);386 .balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);386387387 await helper.getSudo().scheduler.scheduleAt(scheduledSecondId, firstExecutionBlockNumber, {priority: prioHigh, periodic})388 await helper.getSudo().scheduler.scheduleAt(scheduledSecondId, firstExecutionBlockNumber, {priority: prioHigh, periodic})388 .balance.forceTransferToSubstrate(alice, alice.address, bob.address, amount);389 .balance.forceTransferToSubstrate(superuser, alice.address, bob.address, amount);389390390 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');391 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');391392392 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);393 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);393394394 // Flip priorities395 // Flip priorities395 await helper.getSudo().scheduler.changePriority(alice, scheduledFirstId, prioHigh);396 await helper.getSudo().scheduler.changePriority(superuser, scheduledFirstId, prioHigh);396 await helper.getSudo().scheduler.changePriority(alice, scheduledSecondId, prioLow);397 await helper.getSudo().scheduler.changePriority(superuser, scheduledSecondId, prioLow);397398398 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period);399 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period);399400473 let bob: IKeyringPair;474 let bob: IKeyringPair;474475475 before(async function() {476 before(async function() {476 await usingPlaygrounds(async (helper, privateKeyWrapper) => {477 await usingPlaygrounds(async (helper, privateKey) => {477 alice = await privateKeyWrapper('//Alice');478 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);479478 bob = await privateKeyWrapper('//Bob');480 const donor = await privateKey({filename: __filename});479480 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);481 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);481482482 await helper.testUtils.enable();483 await helper.testUtils.enable();483 });484 });581 // let bob: IKeyringPair;582 // let bob: IKeyringPair;582583583 // before(async() => {584 // before(async() => {584 // await usingApi(async (_, privateKeyWrapper) => {585 // await usingApi(async (_, privateKey) => {585 // alice = privateKeyWrapper('//Alice');586 // alice = privateKey('//Alice');586 // bob = privateKeyWrapper('//Bob');587 // bob = privateKey('//Bob');587 // });588 // });588 // });589 // });589590609 });610 });610611611 it('Schedules and dispatches a transaction even if the caller has no funds at the time of the dispatch', async () => {612 it('Schedules and dispatches a transaction even if the caller has no funds at the time of the dispatch', async () => {612 // await usingApi(async (api, privateKeyWrapper) => {613 // await usingApi(async (api, privateKey) => {613 // // Find an empty, unused account614 // // Find an empty, unused account614 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);615 // const zeroBalance = await findUnusedAddress(api, privateKey);615616616 // const collectionId = await createCollectionExpectSuccess();617 // const collectionId = await createCollectionExpectSuccess();617618650 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {651 it('Sponsor going bankrupt does not impact a scheduled transaction', async () => {651 // const collectionId = await createCollectionExpectSuccess();652 // const collectionId = await createCollectionExpectSuccess();652653653 // await usingApi(async (api, privateKeyWrapper) => {654 // await usingApi(async (api, privateKey) => {654 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);655 // const zeroBalance = await findUnusedAddress(api, privateKey);655 // const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);656 // const balanceTx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);656 // await submitTransactionAsync(alice, balanceTx);657 // await submitTransactionAsync(alice, balanceTx);657658681 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);682 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);682 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');683 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');683684684 // await usingApi(async (api, privateKeyWrapper) => {685 // await usingApi(async (api, privateKey) => {685 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);686 // const zeroBalance = await findUnusedAddress(api, privateKey);686687687 // await enablePublicMintingExpectSuccess(alice, collectionId);688 // await enablePublicMintingExpectSuccess(alice, collectionId);688 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);689 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);