git.delta.rocks / unique-network / refs/commits / 26023a4f157f

difftreelog

tests(scheduler): exclude from parallel execution + adapt accounts

Fahrrader2022-11-01parent: #bd896f3.patch.diff
in: master

1 file changed

modifiedtests/src/scheduler.seqtest.tsdiffbeforeafterboth
19import {DevUniqueHelper} from './util/playgrounds/unique.dev';19import {DevUniqueHelper} from './util/playgrounds/unique.dev';
2020
21describe('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;
2526
26 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]);
30
28 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);
31
32 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);
3334
34 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});
310311
311 await helper.getSudo().scheduler.cancelScheduled(alice, scheduledId);312 await helper.getSudo().scheduler.cancelScheduled(superuser, scheduledId);
312313
313 await helper.wait.newBlocks(waitForBlocks + 1);314 await helper.wait.newBlocks(waitForBlocks + 1);
314315
325326
326 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);
329330
330 await helper.wait.newBlocks(waitForBlocks + 1);331 await helper.wait.newBlocks(waitForBlocks + 1);
331332
348 .transfer(bob, {Substrate: alice.address});349 .transfer(bob, {Substrate: alice.address});
349350
350 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);
352353
353 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 });
362363
363 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,
382383
383 // 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 priority
384 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);
386387
387 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);
389390
390 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');391 const capture = await helper.arrange.captureEvents('scheduler', 'Dispatched');
391392
392 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);393 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber);
393394
394 // Flip priorities395 // Flip priorities
395 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);
397398
398 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period);399 await helper.wait.forParachainBlockNumber(firstExecutionBlockNumber + periodic.period);
399400
473 let bob: IKeyringPair;474 let bob: IKeyringPair;
474475
475 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]);
479
478 bob = await privateKeyWrapper('//Bob');480 const donor = await privateKey({filename: __filename});
479
480 requirePalletsOrSkip(this, helper, [Pallets.Scheduler]);481 [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);
481482
482 await helper.testUtils.enable();483 await helper.testUtils.enable();
483 });484 });
581 // let bob: IKeyringPair;582 // let bob: IKeyringPair;
582583
583 // 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 // });
589590
609 });610 });
610611
611 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 account
614 // const zeroBalance = await findUnusedAddress(api, privateKeyWrapper);615 // const zeroBalance = await findUnusedAddress(api, privateKey);
615616
616 // const collectionId = await createCollectionExpectSuccess();617 // const collectionId = await createCollectionExpectSuccess();
617618
650 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();
652653
653 // 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);
657658
681 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);682 // await setCollectionSponsorExpectSuccess(collectionId, bob.address);
682 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');683 // await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
683684
684 // 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);
686687
687 // await enablePublicMintingExpectSuccess(alice, collectionId);688 // await enablePublicMintingExpectSuccess(alice, collectionId);
688 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);689 // await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);