diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-12 04:13:12 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-12 04:13:12 +0800 |
commit | 31fe232bac9c4e8a0ef409fb41188fcb8aa0b3f2 (patch) | |
tree | c3632e81147cd60509f3cfdf8538b9206b995ce7 /packages/order-utils/test | |
parent | 60f5a52964d6965d35eb3c3cb15abc8471de6fd6 (diff) | |
download | dexon-sol-tools-31fe232bac9c4e8a0ef409fb41188fcb8aa0b3f2.tar.gz dexon-sol-tools-31fe232bac9c4e8a0ef409fb41188fcb8aa0b3f2.tar.zst dexon-sol-tools-31fe232bac9c4e8a0ef409fb41188fcb8aa0b3f2.zip |
Remove global hooks from tests and deploy contracts from within the specific tests
Diffstat (limited to 'packages/order-utils/test')
-rw-r--r-- | packages/order-utils/test/exchange_transfer_simulator_test.ts | 41 | ||||
-rw-r--r-- | packages/order-utils/test/global_hooks_test.ts | 45 |
2 files changed, 32 insertions, 54 deletions
diff --git a/packages/order-utils/test/exchange_transfer_simulator_test.ts b/packages/order-utils/test/exchange_transfer_simulator_test.ts index 13e2dcc62..3369901b1 100644 --- a/packages/order-utils/test/exchange_transfer_simulator_test.ts +++ b/packages/order-utils/test/exchange_transfer_simulator_test.ts @@ -1,4 +1,4 @@ -import { BlockchainLifecycle } from '@0xproject/dev-utils'; +import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils'; import { ExchangeContractErrs } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; @@ -9,6 +9,8 @@ import { artifacts } from '../src/artifacts'; import { constants } from '../src/constants'; import { ExchangeTransferSimulator } from '../src/exchange_transfer_simulator'; import { DummyERC20TokenContract } from '../src/generated_contract_wrappers/dummy_e_r_c20_token'; +import { ERC20ProxyContract } from '../src/generated_contract_wrappers/e_r_c20_proxy'; +import { ERC20TokenContract } from '../src/generated_contract_wrappers/e_r_c20_token'; import { BalanceAndProxyAllowanceLazyStore } from '../src/store/balance_and_proxy_allowance_lazy_store'; import { TradeSide, TransferType } from '../src/types'; @@ -31,19 +33,40 @@ describe('ExchangeTransferSimulator', async () => { let exchangeTransferSimulator: ExchangeTransferSimulator; let txHash: string; let erc20ProxyAddress: string; - before(async () => { + before(async function(): Promise<void> { + const mochaTestTimeoutMs = 20000; + this.timeout(mochaTestTimeoutMs); + userAddresses = await web3Wrapper.getAvailableAddressesAsync(); [coinbase, sender, recipient] = userAddresses; - erc20ProxyAddress = getAddressFromArtifact(artifacts.ERC20Proxy, constants.TESTRPC_NETWORK_ID); + const txDefaults = { + gas: devConstants.GAS_LIMIT, + from: devConstants.TESTRPC_FIRST_ADDRESS, + }; + + const erc20Proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync( + artifacts.ERC20Proxy, + provider, + txDefaults, + ); + erc20ProxyAddress = erc20Proxy.address; - const wethArtifact = artifacts.DummyERC20Token; - const wethAddress = getAddressFromArtifact(wethArtifact, constants.TESTRPC_NETWORK_ID); - dummyERC20Token = new DummyERC20TokenContract( - artifacts.DummyERC20Token.compilerOutput.abi, - wethAddress, + const totalSupply = new BigNumber(100000000000000000000); + const name = 'Test'; + const symbol = 'TST'; + const decimals = new BigNumber(18); + // tslint:disable-next-line:no-unused-variable + dummyERC20Token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( + artifacts.DummyERC20Token, provider, + txDefaults, + name, + symbol, + decimals, + totalSupply, ); + exampleTokenAddress = dummyERC20Token.address; }); beforeEach(async () => { @@ -59,7 +82,7 @@ describe('ExchangeTransferSimulator', async () => { beforeEach(() => { const simpleERC20BalanceAndProxyAllowanceFetcher = new SimpleERC20BalanceAndProxyAllowanceFetcher( - dummyERC20Token, + (dummyERC20Token as any) as ERC20TokenContract, erc20ProxyAddress, ); const balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( diff --git a/packages/order-utils/test/global_hooks_test.ts b/packages/order-utils/test/global_hooks_test.ts deleted file mode 100644 index 662a2cb0f..000000000 --- a/packages/order-utils/test/global_hooks_test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { devConstants } from '@0xproject/dev-utils'; -import { ArtifactWriter } from '@0xproject/migrations'; -import { BigNumber } from '@0xproject/utils'; - -import { artifacts } from '../src/artifacts'; -import { constants } from '../src/constants'; -import { DummyERC20TokenContract } from '../src/generated_contract_wrappers/dummy_e_r_c20_token'; -import { ERC20ProxyContract } from '../src/generated_contract_wrappers/e_r_c20_proxy'; - -import { provider } from './utils/web3_wrapper'; - -before('migrate contracts', async function(): Promise<void> { - // HACK: Since contract migrations take longer then our global mocha timeout limit - // we manually increase it for this before hook. - const mochaTestTimeoutMs = 20000; - this.timeout(mochaTestTimeoutMs); - - const txDefaults = { - gas: devConstants.GAS_LIMIT, - from: devConstants.TESTRPC_FIRST_ADDRESS, - }; - - const networkId = constants.TESTRPC_NETWORK_ID; - const artifactsDir = `lib/src/artifacts`; - const artifactsWriter = new ArtifactWriter(artifactsDir, networkId); - - const erc20proxy = await ERC20ProxyContract.deployFrom0xArtifactAsync(artifacts.ERC20Proxy, provider, txDefaults); - artifactsWriter.saveArtifact(erc20proxy); - - const totalSupply = new BigNumber(100000000000000000000); - const name = 'Test'; - const symbol = 'TST'; - const decimals = new BigNumber(18); - // tslint:disable-next-line:no-unused-variable - const dummyErc20Token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( - artifacts.DummyERC20Token, - provider, - txDefaults, - name, - symbol, - decimals, - totalSupply, - ); - artifactsWriter.saveArtifact(dummyErc20Token); -}); |