git.delta.rocks / unique-network / refs/commits / b0b7e382417e

difftreelog

feat add testUtils to dev unique helper

Daniel Shiposha2022-10-11parent: #4ce643d.patch.diff
in: master

1 file changed

modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
8import * as defs from '../../interfaces/definitions';8import * as defs from '../../interfaces/definitions';
9import {IKeyringPair} from '@polkadot/types/types';9import {IKeyringPair} from '@polkadot/types/types';
10import {EventRecord} from '@polkadot/types/interfaces';10import {EventRecord} from '@polkadot/types/interfaces';
11import {ICrossAccountId} from './types';11import {ICrossAccountId, TSigner} from './types';
12import {FrameSystemEventRecord} from '@polkadot/types/lookup';12import {FrameSystemEventRecord} from '@polkadot/types/lookup';
13import {VoidFn} from '@polkadot/api/types';13import {VoidFn} from '@polkadot/api/types';
14import {FrameSystemEventRecord} from '@polkadot/types/lookup';
1514
16export class SilentLogger {15export class SilentLogger {
17 log(_msg: any, _level: any): void { }16 log(_msg: any, _level: any): void { }
65 arrange: ArrangeGroup;64 arrange: ArrangeGroup;
66 wait: WaitGroup;65 wait: WaitGroup;
67 admin: AdminGroup;66 admin: AdminGroup;
67 testUtils: TestUtilGroup;
6868
69 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {69 constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) {
70 options.helperBase = options.helperBase ?? DevUniqueHelper;70 options.helperBase = options.helperBase ?? DevUniqueHelper;
73 this.arrange = new ArrangeGroup(this);73 this.arrange = new ArrangeGroup(this);
74 this.wait = new WaitGroup(this);74 this.wait = new WaitGroup(this);
75 this.admin = new AdminGroup(this);75 this.admin = new AdminGroup(this);
76 this.testUtils = new TestUtilGroup(this);
76 }77 }
7778
78 async connect(wsEndpoint: string, _listeners?: any): Promise<void> {79 async connect(wsEndpoint: string, _listeners?: any): Promise<void> {
478 }479 }
479}480}
481
482class TestUtilGroup {
483 helper: DevUniqueHelper;
484
485 constructor(helper: DevUniqueHelper) {
486 this.helper = helper;
487 }
488
489 async setTestValue(signer: TSigner, testVal: number) {
490 await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValue', [testVal], true);
491 }
492
493 async incTestValue(signer: TSigner) {
494 await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.incTestValue', [], true);
495 }
496
497 async setTestValueAndRollback(signer: TSigner, testVal: number) {
498 await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValueAndRollback', [testVal], true);
499 }
500
501 async testValue() {
502 return (await this.helper.callRpc('api.query.testUtils.testValue', [])).toNumber();
503 }
504
505 async justTakeFee(signer: TSigner) {
506 await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.justTakeFee', [], true);
507 }
508
509 async selfCancelingInc(signer: TSigner, scheduledId: string, maxTestVal: number) {
510 await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.selfCancelingInc', [scheduledId, maxTestVal], true);
511 }
512}
480513
481class EventCapture {514class EventCapture {
482 helper: DevUniqueHelper;515 helper: DevUniqueHelper;