Skip to main content

Module: TestUtils

Utilities to write tests with ethers, waffle and react hooks

Classes

Variables

const_basicGasPrice

Const const_basicGasPrice: 875000000

Defined in

src/helpers/test-utils/constants/testConstants.ts:1


const_DefaultTestChainId

Const const_DefaultTestChainId: 31337

Defined in

src/helpers/test-utils/constants/testConstants.ts:3


defaultBlockWaitOptions

Const defaultBlockWaitOptions: Object

This is a const based on WaitOptions from react testing lib

Type declaration

NameType
timeoutnumber
intervalnumber

Defined in

src/helpers/test-utils/constants/testConstants.ts:9

Functions

mineBlock

mineBlock(mockProvider): Promise<void>

Parameters

NameType
mockProviderMockProvider

Returns

Promise<void>

Defined in

src/helpers/test-utils/eth/hardhatActions.ts:3


setAutoMine

setAutoMine(mockProvider, enabled): Promise<void>

Parameters

NameType
mockProviderMockProvider
enabledboolean

Returns

Promise<void>

Defined in

src/helpers/test-utils/eth/hardhatActions.ts:13


mineBlockUntil

mineBlockUntil(mockProvider, maxNumberOfBlocks, untilCondition): Promise<[success: boolean, currentBlockNumber: number]>

Summary

mine block until the a condition is met or a maximumNumberOfBlocks is reached

Parameters

NameType
mockProviderMockProvider
maxNumberOfBlocksnumber
untilCondition(currentBlockNumber: number) => Promise<boolean> | (currentBlockNumber: number) => boolean | (currentBlockNumber: number) => Promise<void>

Returns

Promise<[success: boolean, currentBlockNumber: number]>

[success, currentBlockNumber]

Defined in

src/helpers/test-utils/eth/hardhatActions.ts:25


fromGwei

fromGwei(value): BigNumber

Parameters

NameType
valuestring | number

Returns

BigNumber

Defined in

src/helpers/test-utils/functions/conversions.ts:3


fromEther

fromEther(value): BigNumber

Parameters

NameType
valuestring | number

Returns

BigNumber

Defined in

src/helpers/test-utils/functions/conversions.ts:7


expectValidWallets

expectValidWallets(...wallets): void

Parameters

NameType
...walletsWallet[]

Returns

void

Defined in

src/helpers/test-utils/functions/expect.ts:4


shouldFailWithMessage

shouldFailWithMessage(failingFunction, errorMessage): Promise<void>

Wrapped around a function to ensure that it fails with the correct message and doesn't pass successfully

Parameters

NameTypeDescription
failingFunction() => Promise<any>Function expect to fail
errorMessagestringError message expect to fail with

Returns

Promise<void>

Defined in

src/helpers/test-utils/functions/shouldFailWithMessage.ts:10


TestAppWrapper

TestAppWrapper(props, context?): null | ReactElement<any, any>

This is a wrapper for tests

Parameters

NameType
propsIMockProps
context?any

Returns

null | ReactElement<any, any>

Defined in

node_modules/@types/react/index.d.ts:520


getMockProvider

getMockProvider(): MockProvider

Returns

MockProvider

Defined in

src/helpers/test-utils/wrapper/getMockProvider.ts:6


wrapperTestSetupHelper

wrapperTestSetupHelper(): Promise<TTestHookResult<(chainId?: number, override?: TOverride) => number>>

Returns

Promise<TTestHookResult<(chainId?: number, override?: TOverride) => number>>

Defined in

src/helpers/test-utils/wrapper/hardhatTestHelpers.ts:4


currentTestBlockNumber

currentTestBlockNumber(): Promise<number>

Returns

Promise<number>

Defined in

src/helpers/test-utils/wrapper/hardhatTestHelpers.ts:12


hookTestWrapper

hookTestWrapper<TCallbackToHook>(callbackToHook): Promise<TTestHookResult<TCallbackToHook>>

Created a test hook with a Web3Wrapper

See

renderHook from

Link

testing-library/react-hooks

Type parameters

NameType
TCallbackToHookextends (input: any) => any

Parameters

NameTypeDescription
callbackToHookTCallbackToHookcallback to init hook

Returns

Promise<TTestHookResult<TCallbackToHook>>

(TTestHookResult)

Defined in

src/helpers/test-utils/wrapper/testWrapper.tsx:28


isActive

isActive(connector): Promise<boolean>

Parameters

NameType
connectorMockConnector

Returns

Promise<boolean>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:8


waitForActivation

waitForActivation(callback): Promise<void>

Parameters

NameType
callback() => Promise<boolean>

Returns

Promise<void>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:17


getTestAccounts

getTestAccounts(provider): Promise<{ deployer: string ; user1: string ; user2: string ; user3: string ; user4: string ; user5: string ; governance: string }>

Parameters

NameType
providerMockProvider

Returns

Promise<{ deployer: string ; user1: string ; user2: string ; user3: string ; user4: string ; user5: string ; governance: string }>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:31


getTestSigners

getTestSigners(provider): Promise<{ deployer: JsonRpcSigner ; user1: JsonRpcSigner ; user2: JsonRpcSigner ; user3: JsonRpcSigner ; user4: JsonRpcSigner ; user5: JsonRpcSigner ; governance: JsonRpcSigner }>

Parameters

NameType
providerMockProvider

Returns

Promise<{ deployer: JsonRpcSigner ; user1: JsonRpcSigner ; user2: JsonRpcSigner ; user3: JsonRpcSigner ; user4: JsonRpcSigner ; user5: JsonRpcSigner ; governance: JsonRpcSigner }>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:47


getHardhatAccount

getHardhatAccount(provider, hardhatAccountIndex): Promise<string>

Parameters

NameType
providerMockProvider
hardhatAccountIndexnumber

Returns

Promise<string>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:63


getHardhatSigner

getHardhatSigner(provider, hardhatAccountIndex): Promise<Signer>

Parameters

NameType
providerMockProvider
hardhatAccountIndexnumber

Returns

Promise<Signer>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:73

Type Aliases

TTestHookResult

Ƭ TTestHookResult<TCallbackToHook>: Omit<RenderHookResult<Parameters<TCallbackToHook>, ReturnType<TCallbackToHook>>, "rerender"> & { mockProvider: MockProvider ; rerender: (input: Parameters<TCallbackToHook>[0]) => void }

Type parameters

NameType
TCallbackToHookextends (input: any) => any

Defined in

src/helpers/test-utils/wrapper/testWrapper.tsx:14


THardhatAccountsNames

Ƭ THardhatAccountsNames: "deployer" | "user1" | "user2" | "user3" | "user4" | "user5" | "governance"

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:28


THardhatAccounts

Ƭ THardhatAccounts: Record<THardhatAccountsNames, SignerWithAddress>

Defined in

src/helpers/test-utils/wrapper/wrapperHelpers.ts:30