difftreelog
test(itest) rescheduling always works
in: master
1 file changed
tests/src/scheduler.seqtest.tsdiffbeforeafterboth410 expect(secondExecuctionIds[1]).to.be.equal(scheduledSecondId);410 expect(secondExecuctionIds[1]).to.be.equal(scheduledSecondId);411 });411 });412413 itSub.ifWithPallets('Periodic operations always can be rescheduled', [Pallets.Scheduler], async ({helper}) => {414 const maxScheduledPerBlock = 50;415 const numFilledBlocks = 3;416 const ids = await helper.arrange.makeScheduledIds(numFilledBlocks * maxScheduledPerBlock + 1);417 const periodicId = ids[0];418 const fillIds = ids.slice(1);419420 const initTestVal = 0;421 const firstExecTestVal = 1;422 const secondExecTestVal = 2;423 await helper.testUtils.setTestValue(alice, initTestVal);424425 const currentBlockNumber = await helper.chain.getLatestBlockNumber();426 const blocksBeforeExecution = 8;427 const firstExecutionBlockNumber = currentBlockNumber + blocksBeforeExecution;428429 const period = 5;430431 const periodic = {432 period,433 repetitions: 2,434 };435436 // Fill `numFilledBlocks` blocks beginning from the block in which the second execution should occur437 const txs = [];438 for (let offset = 0; offset < numFilledBlocks; offset ++) {439 for (let i = 0; i < maxScheduledPerBlock; i++) {440441 const scheduledTx = helper.constructApiCall('api.tx.balances.transfer', [bob.address, 1n]);442443 const when = firstExecutionBlockNumber + period + offset;444 const tx = helper.constructApiCall('api.tx.scheduler.scheduleNamed', [fillIds[i + offset * maxScheduledPerBlock], when, null, null, scheduledTx]);445446 txs.push(tx);447 }448 }449 await helper.executeExtrinsic(alice, 'api.tx.testUtils.batchAll', [txs], true);450451 await helper.scheduler.scheduleAt<DevUniqueHelper>(periodicId, firstExecutionBlockNumber, {periodic})452 .testUtils.incTestValue(alice);453454 await helper.wait.newBlocks(blocksBeforeExecution);455 expect(await helper.testUtils.testValue()).to.be.equal(firstExecTestVal);456457 await helper.wait.newBlocks(period + numFilledBlocks);458459 // The periodic operation should be postponed by `numFilledBlocks`460 for (let i = 0; i < numFilledBlocks; i++) {461 expect(await helper.testUtils.testValue(firstExecutionBlockNumber + period + i)).to.be.equal(firstExecTestVal);462 }463464 // After the `numFilledBlocks` the periodic operation will eventually be executed465 expect(await helper.testUtils.testValue()).to.be.equal(secondExecTestVal);466 });412});467});413468414describe('Negative Test: Scheduling', () => {469describe('Negative Test: Scheduling', () => {