difftreelog
fix(test) add generateKeyringPair
in: master
1 file changed
tests/src/util/helpers.tsdiffbeforeafterboth161617import '../interfaces/augment-api-rpc';17import '../interfaces/augment-api-rpc';18import '../interfaces/augment-api-query';18import '../interfaces/augment-api-query';19import {ApiPromise} 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 type {GenericEventData} from '@polkadot/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';1786itApi.only = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {only: true});1786itApi.only = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {only: true});1787itApi.skip = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {skip: true});1787itApi.skip = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {skip: true});17881789let accountSeed = 10000;17901791const keyringEth = new Keyring({type: 'ethereum'});1792const keyringEd25519 = new Keyring({type: 'ed25519'});1793const keyringSr25519 = new Keyring({type: 'sr25519'});17941795export function generateKeyringPair(type: 'ethereum' | 'sr25519' | 'ed25519' = 'sr25519') {1796 const privateKey = `0xDEADBEEF${(accountSeed++).toString(16).padStart(56, '0')}`;1797 if (type == 'sr25519') {1798 return keyringSr25519.addFromUri(privateKey);1799 } else if (type == 'ed25519') {1800 return keyringEd25519.addFromUri(privateKey);1801 }1802 return keyringEth.addFromUri(privateKey);1803}17881804