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
Name | Type |
---|---|
timeout | number |
interval | number |
Defined in
src/helpers/test-utils/constants/testConstants.ts:9
Functions
mineBlock
▸ mineBlock(mockProvider
): Promise
<void
>
Parameters
Name | Type |
---|---|
mockProvider | MockProvider |
Returns
Promise
<void
>
Defined in
src/helpers/test-utils/eth/hardhatActions.ts:3
setAutoMine
▸ setAutoMine(mockProvider
, enabled
): Promise
<void
>
Parameters
Name | Type |
---|---|
mockProvider | MockProvider |
enabled | boolean |
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
Name | Type |
---|---|
mockProvider | MockProvider |
maxNumberOfBlocks | number |
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
Name | Type |
---|---|
value | string | number |
Returns
BigNumber
Defined in
src/helpers/test-utils/functions/conversions.ts:3
fromEther
▸ fromEther(value
): BigNumber
Parameters
Name | Type |
---|---|
value | string | number |
Returns
BigNumber
Defined in
src/helpers/test-utils/functions/conversions.ts:7
expectValidWallets
▸ expectValidWallets(...wallets
): void
Parameters
Name | Type |
---|---|
...wallets | Wallet [] |
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
Name | Type | Description |
---|---|---|
failingFunction | () => Promise <any > | Function expect to fail |
errorMessage | string | Error 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
Name | Type |
---|---|
props | IMockProps |
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
Name | Type |
---|---|
TCallbackToHook | extends (input : any ) => any |
Parameters
Name | Type | Description |
---|---|---|
callbackToHook | TCallbackToHook | callback to init hook |
Returns
Promise
<TTestHookResult
<TCallbackToHook
>>
(TTestHookResult)
Defined in
src/helpers/test-utils/wrapper/testWrapper.tsx:28
isActive
▸ isActive(connector
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
connector | MockConnector |
Returns
Promise
<boolean
>
Defined in
src/helpers/test-utils/wrapper/wrapperHelpers.ts:8
waitForActivation
▸ waitForActivation(callback
): Promise
<void
>
Parameters
Name | Type |
---|---|
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
Name | Type |
---|---|
provider | MockProvider |
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
Name | Type |
---|---|
provider | MockProvider |
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
Name | Type |
---|---|
provider | MockProvider |
hardhatAccountIndex | number |
Returns
Promise
<string
>
Defined in
src/helpers/test-utils/wrapper/wrapperHelpers.ts:63
getHardhatSigner
▸ getHardhatSigner(provider
, hardhatAccountIndex
): Promise
<Signer
>
Parameters
Name | Type |
---|---|
provider | MockProvider |
hardhatAccountIndex | number |
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
Name | Type |
---|---|
TCallbackToHook | extends (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
>