From b0b7e382417e14005f8f3d14675790f1c374c43c Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Tue, 11 Oct 2022 17:40:15 +0000 Subject: [PATCH] feat: add testUtils to dev unique helper --- --- a/tests/src/util/playgrounds/unique.dev.ts +++ b/tests/src/util/playgrounds/unique.dev.ts @@ -8,10 +8,9 @@ import * as defs from '../../interfaces/definitions'; import {IKeyringPair} from '@polkadot/types/types'; import {EventRecord} from '@polkadot/types/interfaces'; -import {ICrossAccountId} from './types'; +import {ICrossAccountId, TSigner} from './types'; import {FrameSystemEventRecord} from '@polkadot/types/lookup'; import {VoidFn} from '@polkadot/api/types'; -import {FrameSystemEventRecord} from '@polkadot/types/lookup'; export class SilentLogger { log(_msg: any, _level: any): void { } @@ -65,6 +64,7 @@ arrange: ArrangeGroup; wait: WaitGroup; admin: AdminGroup; + testUtils: TestUtilGroup; constructor(logger: { log: (msg: any, level: any) => void, level: any }, options: {[key: string]: any} = {}) { options.helperBase = options.helperBase ?? DevUniqueHelper; @@ -73,6 +73,7 @@ this.arrange = new ArrangeGroup(this); this.wait = new WaitGroup(this); this.admin = new AdminGroup(this); + this.testUtils = new TestUtilGroup(this); } async connect(wsEndpoint: string, _listeners?: any): Promise { @@ -478,6 +479,38 @@ } } +class TestUtilGroup { + helper: DevUniqueHelper; + + constructor(helper: DevUniqueHelper) { + this.helper = helper; + } + + async setTestValue(signer: TSigner, testVal: number) { + await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValue', [testVal], true); + } + + async incTestValue(signer: TSigner) { + await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.incTestValue', [], true); + } + + async setTestValueAndRollback(signer: TSigner, testVal: number) { + await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.setTestValueAndRollback', [testVal], true); + } + + async testValue() { + return (await this.helper.callRpc('api.query.testUtils.testValue', [])).toNumber(); + } + + async justTakeFee(signer: TSigner) { + await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.justTakeFee', [], true); + } + + async selfCancelingInc(signer: TSigner, scheduledId: string, maxTestVal: number) { + await this.helper.executeExtrinsic(signer, 'api.tx.testUtils.selfCancelingInc', [scheduledId, maxTestVal], true); + } +} + class EventCapture { helper: DevUniqueHelper; eventSection: string; -- gitstuff