git.delta.rocks / unique-network / refs/commits / 07b1ed59621c

difftreelog

test scheduler should be transactional

Daniel Shiposha2022-08-18parent: #7f83e96.patch.diff
in: master

2 files changed

modifiedtests/src/.outdated/scheduler.test.tsdiffbeforeafterboth
19import {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;
8184
82 before(async() => {85 before(async function() {
86 await requirePallets(this, [Pallets.Scheduler]);
87
83 await usingApi(async (_, privateKeyWrapper) => {88 await usingApi(async (_, privateKeyWrapper) => {
84 alice = privateKeyWrapper('//Alice');89 alice = privateKeyWrapper('//Alice');
175 });180 });
176 });181 });
182
183 it('Scheduled tasks are transactional', async function() {
184 await requirePallets(this, [Pallets.TestUtils]);
185
186 await usingApi(async api => {
187 const scheduledId = makeScheduledId();
188 const waitForBlocks = 4;
189 const period = null;
190 const priority = 0;
191
192 const initTestVal = 42;
193 const changedTestVal = 111;
194
195 const initTx = api.tx.testUtils.setTestValue(initTestVal);
196 await submitTransactionAsync(alice, initTx);
197
198 const changeErrTx = api.tx.testUtils.setTestValueAndRollback(changedTestVal);
199
200 const scheduleTx = api.tx.scheduler.scheduleNamedAfter(
201 scheduledId,
202 waitForBlocks,
203 period,
204 priority,
205 {Value: changeErrTx as any},
206 );
207
208 await submitTransactionAsync(alice, scheduleTx);
209
210 await waitNewBlocks(waitForBlocks);
211
212 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 });
177218
178 // 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;
221262
222 before(async() => {263 before(async function() {
264 await requirePallets(this, [Pallets.Scheduler]);
265
223 await usingApi(async (_, privateKeyWrapper) => {266 await usingApi(async (_, privateKeyWrapper) => {
224 alice = privateKeyWrapper('//Alice');267 alice = privateKeyWrapper('//Alice');
modifiedtests/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> {