difftreelog
test(rmrk-proxy) sample externality test
in: master
3 files changed
tests/package.jsondiffbeforeafterboth37 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",37 "testStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/**.test.ts",38 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts",38 "testProperties": "mocha --timeout 9999999 -r ts-node/register ./**/properties.test.ts",39 "testMigrationStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",39 "testMigrationStructure": "mocha --timeout 9999999 -r ts-node/register ./**/nesting/migration-check.test.ts",40 "testRmrk": "mocha --timeout 9999999 -r ts-node/register ./**/rmrk/**.test.ts",40 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",41 "testAddCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/addCollectionAdmin.test.ts",41 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",42 "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",42 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",43 "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",tests/src/rmrk/rmrk.test.tsdiffbeforeafterbothno changes
tests/src/util/helpers.tsdiffbeforeafterboth18import '../interfaces/augment-api-query';18import '../interfaces/augment-api-query';19import {ApiPromise, Keyring} from '@polkadot/api';19import {ApiPromise, Keyring} from '@polkadot/api';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';21import type {GenericEventData} from '@polkadot/types';21import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';22import {evmToAddress} from '@polkadot/util-crypto';23import {evmToAddress} from '@polkadot/util-crypto';23import BN from 'bn.js';24import BN from 'bn.js';88const CENTIUNIQUE = 10n * MILLIUNIQUE;89const CENTIUNIQUE = 10n * MILLIUNIQUE;89export const UNIQUE = 100n * CENTIUNIQUE;90export const UNIQUE = 100n * CENTIUNIQUE;909191type GenericResult = {92interface GenericResult<T> {92 success: boolean,93 success: boolean;94 data: T | null;93};95}949695interface CreateCollectionResult {97interface CreateCollectionResult {96 success: boolean;98 success: boolean;170 return event.event as T;172 return event.event as T;171}173}172174173export function getGenericResult(events: EventRecord[]): GenericResult {175export function getGenericResult<T>(176 events: EventRecord[],177 expectSection?: string,178 expectMethod?: string,179 extractAction?: (data: GenericEventData) => T,180): GenericResult<T> {174 const result: GenericResult = {181 let success = false;175 success: false,182 let successData = null;176 };177 events.forEach(({event: {method}}) => {183 events.forEach(({event: {data, method, section}}) => {178 // console.log(` ${phase}: ${section}.${method}:: ${data}`);179 if (method === 'ExtrinsicSuccess') {184 if (method === 'ExtrinsicSuccess') {180 result.success = true;185 success = true;181 }186 } else if ((expectSection == section) && (expectMethod == method)) {187 successData = extractAction!(data);188 }182 });189 });190 const result: GenericResult<T> = {191 success,192 data: successData,193 };183 return result;194 return result;184}195}185