difftreelog
test scheduler should be transactional
in: master
2 files changed
tests/src/.outdated/scheduler.test.tsdiffbeforeafterboth19import {19import {20 default as usingApi,20 default as usingApi,21 submitTransactionAsync,21 submitTransactionAsync,22 submitTransactionExpectFailAsync,22} from '../substrate/substrate-api';23} from '../substrate/substrate-api';23import {24import {24 createItemExpectSuccess,25 createItemExpectSuccess,41 scheduleExpectFailure,42 scheduleExpectFailure,42 scheduleAfter,43 scheduleAfter,43 cancelScheduled,44 cancelScheduled,45 requirePallets,46 Pallets,44} from '../deprecated-helpers/helpers';47} from '../deprecated-helpers/helpers';45import {IKeyringPair} from '@polkadot/types/types';48import {IKeyringPair} from '@polkadot/types/types';46import {ApiPromise} from '@polkadot/api';49import {ApiPromise} from '@polkadot/api';79 let alice: IKeyringPair;82 let alice: IKeyringPair;80 let bob: IKeyringPair;83 let bob: IKeyringPair;818482 before(async() => {85 before(async function() {86 await requirePallets(this, [Pallets.Scheduler]);8783 await usingApi(async (_, privateKeyWrapper) => {88 await usingApi(async (_, privateKeyWrapper) => {84 alice = privateKeyWrapper('//Alice');89 alice = privateKeyWrapper('//Alice');175 });180 });176 });181 });182183 it('Scheduled tasks are transactional', async function() {184 await requirePallets(this, [Pallets.TestUtils]);185186 await usingApi(async api => {187 const scheduledId = makeScheduledId();188 const waitForBlocks = 4;189 const period = null;190 const priority = 0;191192 const initTestVal = 42;193 const changedTestVal = 111;194195 const initTx = api.tx.testUtils.setTestValue(initTestVal);196 await submitTransactionAsync(alice, initTx);197198 const changeErrTx = api.tx.testUtils.setTestValueAndRollback(changedTestVal);199200 const scheduleTx = api.tx.scheduler.scheduleNamedAfter(201 scheduledId,202 waitForBlocks, 203 period,204 priority, 205 {Value: changeErrTx as any},206 );207208 await submitTransactionAsync(alice, scheduleTx);209210 await waitNewBlocks(waitForBlocks);211212 const testVal = (await api.query.testUtils.testValue()).toNumber();213 expect(testVal, 'The test value should NOT be commited')214 .not.to.be.equal(changedTestVal)215 .and.to.be.equal(initTx);216 });217 });177218178 // FIXME What purpose of this test?219 // FIXME What purpose of this test?179 it.skip('Can schedule a scheduled operation of canceling the scheduled operation', async () => {220 it.skip('Can schedule a scheduled operation of canceling the scheduled operation', async () => {219 let alice: IKeyringPair;260 let alice: IKeyringPair;220 let bob: IKeyringPair;261 let bob: IKeyringPair;221262222 before(async() => {263 before(async function() {264 await requirePallets(this, [Pallets.Scheduler]);265223 await usingApi(async (_, privateKeyWrapper) => {266 await usingApi(async (_, privateKeyWrapper) => {224 alice = privateKeyWrapper('//Alice');267 alice = privateKeyWrapper('//Alice');tests/src/deprecated-helpers/helpers.tsdiffbeforeafterboth--- a/tests/src/deprecated-helpers/helpers.ts
+++ b/tests/src/deprecated-helpers/helpers.ts
@@ -50,6 +50,7 @@
NFT = 'nonfungible',
Scheduler = 'scheduler',
AppPromotion = 'apppromotion',
+ TestUtils = 'testutils',
}
export async function isUnique(): Promise<boolean> {