Test fixes, pass window.web3 to getProviderInfo in test utils, fix creating safe contracts in test env, dep bump
This commit is contained in:
parent
db54ad812e
commit
ede2ebbbe1
|
@ -3,6 +3,7 @@ import contract from 'truffle-contract'
|
|||
import ProxyFactorySol from '@gnosis.pm/safe-contracts/build/contracts/ProxyFactory.json'
|
||||
import GnosisSafeSol from '@gnosis.pm/safe-contracts/build/contracts/GnosisSafe.json'
|
||||
import SafeProxy from '@gnosis.pm/safe-contracts/build/contracts/Proxy.json'
|
||||
import { ensureOnce } from '~/utils/singleton'
|
||||
import { simpleMemoize } from '~/components/forms/validator'
|
||||
import { getWeb3 } from '~/logic/wallets/getWeb3'
|
||||
import { calculateGasOf, calculateGasPrice } from '~/logic/wallets/ethTransactions'
|
||||
|
@ -30,7 +31,7 @@ const createProxyFactoryContract = (web3: any) => {
|
|||
export const getGnosisSafeContract = simpleMemoize(createGnosisSafeContract)
|
||||
const getCreateProxyFactoryContract = simpleMemoize(createProxyFactoryContract)
|
||||
|
||||
const instanciateMasterCopies = async () => {
|
||||
const instantiateMasterCopies = async () => {
|
||||
const web3 = getWeb3()
|
||||
|
||||
// Create ProxyFactory Master Copy
|
||||
|
@ -55,7 +56,7 @@ const createMasterCopies = async () => {
|
|||
safeMaster = await GnosisSafe.new({ from: userAccount, gas: '7000000' })
|
||||
}
|
||||
|
||||
export const initContracts = process.env.NODE_ENV === 'test' ? createMasterCopies : instanciateMasterCopies
|
||||
export const initContracts = process.env.NODE_ENV === 'test' ? ensureOnce(createMasterCopies) : instantiateMasterCopies
|
||||
|
||||
export const getSafeMasterContract = async () => {
|
||||
await initContracts()
|
||||
|
|
|
@ -15,7 +15,7 @@ import { type SelectorProps } from '~/routes/load/container/selector'
|
|||
|
||||
const getSteps = () => ['Name and address', 'Owners', 'Review']
|
||||
|
||||
type Props = SelectorProps & {
|
||||
export type LayoutProps = SelectorProps & {
|
||||
onLoadSafeSubmit: (values: Object) => Promise<void>,
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import { shortVersionOf } from '~/logic/wallets/ethAddresses'
|
|||
import { getAccountsFrom } from '~/routes/open/utils/safeDataExtractor'
|
||||
import { getOwnerNameBy, getOwnerAddressBy, getNumOwnersFrom } from '~/routes/open/components/fields'
|
||||
import { FIELD_LOAD_NAME, FIELD_LOAD_ADDRESS, THRESHOLD } from '~/routes/load/components/fields'
|
||||
import type { LayoutProps } from '../Layout'
|
||||
|
||||
const styles = () => ({
|
||||
root: {
|
||||
|
|
|
@ -115,7 +115,7 @@ export const whenSafeDeployed = (): Promise<string> => new Promise((resolve, rej
|
|||
const interval = setInterval(() => {
|
||||
if (times >= MAX_TIMES_EXECUTED) {
|
||||
clearInterval(interval)
|
||||
reject()
|
||||
reject(new Error('Didn\'t load the safe'))
|
||||
}
|
||||
const url = `${window.location}`
|
||||
console.log(url)
|
||||
|
|
|
@ -31,7 +31,7 @@ afterAll(() => {
|
|||
})
|
||||
|
||||
const renderOpenSafeForm = async (localStore: Store<GlobalState>) => {
|
||||
const provider = await getProviderInfo()
|
||||
const provider = await getProviderInfo(window.web3.currentProvider)
|
||||
const walletRecord = makeProvider(provider)
|
||||
localStore.dispatch(addProvider(walletRecord))
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ describe('DOM > Feature > Sending Funds', () => {
|
|||
|
||||
// WHEN
|
||||
const SafeDom = renderSafeView(store, safeAddress)
|
||||
await sleep(3500)
|
||||
await sleep(1300)
|
||||
|
||||
// Open send funds modal
|
||||
const balanceRows = SafeDom.getAllByTestId(BALANCE_ROW_TEST_ID)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import * as React from 'react'
|
||||
import { type Store } from 'redux'
|
||||
import { Provider } from 'react-redux'
|
||||
import { render, fireEvent } from '@testing-library/react'
|
||||
import { render, fireEvent, act } from '@testing-library/react'
|
||||
import { ConnectedRouter } from 'connected-react-router'
|
||||
import Load from '~/routes/load/container/Load'
|
||||
import { aNewStore, history, type GlobalState } from '~/store'
|
||||
|
@ -29,7 +29,7 @@ afterAll(() => {
|
|||
})
|
||||
|
||||
const renderLoadSafe = async (localStore: Store<GlobalState>) => {
|
||||
const provider = await getProviderInfo()
|
||||
const provider = await getProviderInfo(window.web3.currentProvider)
|
||||
const walletRecord = makeProvider(provider)
|
||||
localStore.dispatch(addProvider(walletRecord))
|
||||
|
||||
|
@ -52,19 +52,18 @@ describe('DOM > Feature > LOAD a Safe', () => {
|
|||
const safeAddressInput = LoadSafePage.getByPlaceholderText('Safe Address*')
|
||||
|
||||
// Fill Safe's name
|
||||
await act(async () => {
|
||||
fireEvent.change(safeNameInput, { target: { value: 'A Safe To Load' } })
|
||||
fireEvent.change(safeAddressInput, { target: { value: address } })
|
||||
await sleep(400)
|
||||
// Click next
|
||||
fireEvent.submit(form)
|
||||
await sleep(400)
|
||||
|
||||
// submit form with owners names
|
||||
await sleep(500)
|
||||
fireEvent.submit(form)
|
||||
await sleep(400)
|
||||
|
||||
// Submit
|
||||
await sleep(500)
|
||||
fireEvent.submit(form)
|
||||
})
|
||||
|
||||
const deployedAddress = await whenSafeDeployed()
|
||||
expect(deployedAddress).toBe(address)
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ import { aNewStore } from '~/store'
|
|||
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
||||
import { renderSafeView } from '~/test/builder/safe.dom.utils'
|
||||
import '@testing-library/jest-dom/extend-expect'
|
||||
import { TOGGLE_SIDEBAR_BTN_TESTID } from '~/components/Header/component/SafeListHeader'
|
||||
import { TOGGLE_SIDEBAR_BTN_TESTID } from '~/components/Header/components/SafeListHeader'
|
||||
import { SIDEBAR_SAFELIST_ROW_TESTID } from '~/components/Sidebar/SafeList'
|
||||
import { sleep } from '~/utils/timer'
|
||||
|
||||
|
|
Loading…
Reference in New Issue