diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-05 11:05:26 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-12 10:37:27 +0800 |
commit | 13299158d1e22d1af1cd36434fc403a74743ecb1 (patch) | |
tree | 9b35435c6f8641d2dc3d7bfd530c7c4f040a1f51 /packages/contracts | |
parent | a6571b09d2087ffb9a4860c0db3d7344321fe2c3 (diff) | |
download | dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.tar dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.tar.gz dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.tar.bz2 dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.tar.lz dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.tar.xz dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.tar.zst dexon-sol-tools-13299158d1e22d1af1cd36434fc403a74743ecb1.zip |
Add sol-cover implementation
Diffstat (limited to 'packages/contracts')
22 files changed, 233 insertions, 47 deletions
diff --git a/packages/contracts/migrations/config/multisig_sample.ts b/packages/contracts/migrations/config/multisig_sample.ts new file mode 100644 index 000000000..bc2502fca --- /dev/null +++ b/packages/contracts/migrations/config/multisig_sample.ts @@ -0,0 +1,10 @@ +import { MultiSigConfigByNetwork } from '../types'; + +// Make a copy of this file named `multisig.js` and input custom params as needed +export const multiSig: MultiSigConfigByNetwork = { + kovan: { + owners: [], + confirmationsRequired: 0, + secondsRequired: 0, + }, +}; diff --git a/packages/contracts/migrations/config/token_info.ts b/packages/contracts/migrations/config/token_info.ts new file mode 100644 index 000000000..5fd3db144 --- /dev/null +++ b/packages/contracts/migrations/config/token_info.ts @@ -0,0 +1,40 @@ +import { constants } from '../../util/constants'; +import { Token } from '../types'; + +export const tokenInfo: Token[] = [ + { + name: 'Augur Reputation Token', + symbol: 'REP', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }, + { + name: 'Digix DAO Token', + symbol: 'DGD', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }, + { + name: 'Golem Network Token', + symbol: 'GNT', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }, + { + name: 'MakerDAO', + symbol: 'MKR', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }, + { + name: 'Melon Token', + symbol: 'MLN', + decimals: 18, + ipfsHash: constants.NULL_BYTES, + swarmHash: constants.NULL_BYTES, + }, +]; diff --git a/packages/contracts/migrations/index.ts b/packages/contracts/migrations/index.ts new file mode 100644 index 000000000..a44d011da --- /dev/null +++ b/packages/contracts/migrations/index.ts @@ -0,0 +1,20 @@ +import { Deployer } from '@0xproject/deployer'; +import { devConstants } from '@0xproject/dev-utils'; +import * as path from 'path'; + +import { constants } from '../util/constants'; + +import { runMigrationsAsync } from './migrate'; + +const deployerOpts = { + artifactsDir: path.resolve('src', 'artifacts'), + jsonrpcPort: devConstants.RPC_PORT, + networkId: constants.TESTRPC_NETWORK_ID, + defaults: { + gas: devConstants.GAS_ESTIMATE, + }, +}; + +export const deployer = new Deployer(deployerOpts); + +runMigrationsAsync(deployer).catch(console.log); diff --git a/packages/contracts/migrations/migrate.ts b/packages/contracts/migrations/migrate.ts new file mode 100644 index 000000000..d541c892e --- /dev/null +++ b/packages/contracts/migrations/migrate.ts @@ -0,0 +1,90 @@ +import { Deployer } from '@0xproject/deployer'; +import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; + +import { constants } from '../util/constants'; +import { ContractName } from '../util/types'; + +import { tokenInfo } from './config/token_info'; + +/** + * Custom migrations should be defined in this function. This will be called with the CLI 'migrate' command. + * Some operations might be completed in parallel, but we don't do that on purpose. + * That way the addresses are deterministic. + * @param deployer Deployer instance. + */ +export const runMigrationsAsync = async (deployer: Deployer) => { + const web3Wrapper: Web3Wrapper = deployer.web3Wrapper; + const accounts: string[] = await web3Wrapper.getAvailableAddressesAsync(); + + const tokenTransferProxy = await deployer.deployAndSaveAsync(ContractName.TokenTransferProxy); + const zrxToken = await deployer.deployAndSaveAsync(ContractName.ZRXToken); + const etherToken = await deployer.deployAndSaveAsync(ContractName.EtherToken); + const tokenReg = await deployer.deployAndSaveAsync(ContractName.TokenRegistry); + + const exchangeArgs = [zrxToken.address, tokenTransferProxy.address]; + const owners = [accounts[0], accounts[1]]; + const confirmationsRequired = new BigNumber(2); + const secondsRequired = new BigNumber(0); + const multiSigArgs = [owners, confirmationsRequired, secondsRequired, tokenTransferProxy.address]; + const exchange = await deployer.deployAndSaveAsync(ContractName.Exchange, exchangeArgs); + const multiSig = await deployer.deployAndSaveAsync( + ContractName.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress, + multiSigArgs, + ); + + const owner = accounts[0]; + await tokenTransferProxy.addAuthorizedAddress.sendTransactionAsync(exchange.address, { from: owner }); + await tokenTransferProxy.transferOwnership.sendTransactionAsync(multiSig.address, { from: owner }); + const addTokenGasEstimate = await tokenReg.addToken.estimateGasAsync( + zrxToken.address, + tokenInfo[0].name, + tokenInfo[0].symbol, + tokenInfo[0].decimals, + tokenInfo[0].ipfsHash, + tokenInfo[0].swarmHash, + { from: owner }, + ); + await tokenReg.addToken.sendTransactionAsync( + zrxToken.address, + '0x Protocol Token', + 'ZRX', + 18, + constants.NULL_BYTES, + constants.NULL_BYTES, + { + from: owner, + gas: addTokenGasEstimate, + }, + ); + await tokenReg.addToken.sendTransactionAsync( + etherToken.address, + 'Ether Token', + 'WETH', + 18, + constants.NULL_BYTES, + constants.NULL_BYTES, + { + from: owner, + gas: addTokenGasEstimate, + }, + ); + for (const token of tokenInfo) { + const totalSupply = new BigNumber(0); + const args = [token.name, token.symbol, token.decimals, totalSupply]; + const dummyToken = await deployer.deployAsync(ContractName.DummyToken, args); + await tokenReg.addToken.sendTransactionAsync( + dummyToken.address, + token.name, + token.symbol, + token.decimals, + token.ipfsHash, + token.swarmHash, + { + from: owner, + gas: addTokenGasEstimate, + }, + ); + } +}; diff --git a/packages/contracts/migrations/types.ts b/packages/contracts/migrations/types.ts new file mode 100644 index 000000000..58d1e5b4f --- /dev/null +++ b/packages/contracts/migrations/types.ts @@ -0,0 +1,23 @@ +export interface MultiSigConfig { + owners: string[]; + confirmationsRequired: number; + secondsRequired: number; +} + +export interface MultiSigConfigByNetwork { + [networkName: string]: MultiSigConfig; +} + +export interface Token { + address?: string; + name: string; + symbol: string; + decimals: number; + ipfsHash: string; + swarmHash: string; +} + +export interface TokenInfoByNetwork { + development: Token[]; + live: Token[]; +} diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 3f7c70c02..7a75dd40a 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -13,13 +13,18 @@ "copy_artifacts": "copyfiles './src/artifacts/**/*' ./lib", "build": "tsc", "test": "run-s build run_mocha", - "run_mocha": "mocha 'lib/test/**/*.js' --timeout 10000 --bail --exit", + "test:coverage": "COVERAGE=true run-s build run_mocha coverage:report:text", + "run_mocha": "mocha 'lib/test/**/*.js' --timeout 10000000 --bail --exit", "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts", "clean": "shx rm -rf ./lib", "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", - "migrate": "node ../deployer/lib/src/cli.js migrate", + "migrate": "yarn build && yarn compile && node ./lib/migrations/index.js", "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'", + "coverage:report:text": "istanbul report text", + "coverage:report:html": "istanbul report html && open coverage/lcov-report/index.html", + "coverage:report:lcov": "istanbul report lcov", + "coverage:report:coveralls": "yarn coverage:report:lcov && cat coverage/lcov.info | coveralls", "test:circleci": "yarn test" }, "config": { @@ -49,6 +54,7 @@ "chai-bignumber": "^2.0.1", "chai-typescript-typings": "^0.0.4", "copyfiles": "^1.2.0", + "coveralls": "^3.0.0", "dirty-chai": "^2.0.1", "ethers-typescript-typings": "^0.0.2", "mocha": "^4.0.1", diff --git a/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol index 997bb86c0..79fd92029 100644 --- a/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol @@ -363,4 +363,3 @@ contract MultiSigWallet { _transactionIds[i - from] = transactionIdsTemp[i]; } } - diff --git a/packages/contracts/test/ether_token.ts b/packages/contracts/test/ether_token.ts index 4c70534ee..6c7354c2b 100644 --- a/packages/contracts/test/ether_token.ts +++ b/packages/contracts/test/ether_token.ts @@ -9,12 +9,11 @@ import { ContractName } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; import { deployer } from './utils/deployer'; +import { web3, web3Wrapper } from './utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('EtherToken', () => { let account: string; diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 710d6fe94..e276d11b3 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -22,12 +22,11 @@ import { OrderFactory } from '../../util/order_factory'; import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; +import { web3, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('Exchange', () => { let maker: string; diff --git a/packages/contracts/test/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts index 625234729..080cbe5fd 100644 --- a/packages/contracts/test/exchange/helpers.ts +++ b/packages/contracts/test/exchange/helpers.ts @@ -17,13 +17,12 @@ import { OrderFactory } from '../../util/order_factory'; import { ContractName } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; +import { web3, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('Exchange', () => { let maker: string; diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index 239f13a4f..0d3e18711 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -22,12 +22,11 @@ import { OrderFactory } from '../../util/order_factory'; import { BalancesByOwner, ContractName } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; +import { web3, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('Exchange', () => { let maker: string; diff --git a/packages/contracts/test/global_hooks.ts b/packages/contracts/test/global_hooks.ts new file mode 100644 index 000000000..23a99b47c --- /dev/null +++ b/packages/contracts/test/global_hooks.ts @@ -0,0 +1,8 @@ +import { getCoverageSubprovider } from '@0xproject/dev-utils'; + +after('generate coverage report', async () => { + if (process.env.COVERAGE) { + const coverageSubprovider = getCoverageSubprovider(); + await coverageSubprovider.writeCoverageAsync(); + } +}); diff --git a/packages/contracts/test/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts index a726814e4..d35efe9da 100644 --- a/packages/contracts/test/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/multi_sig_with_time_lock.ts @@ -1,5 +1,5 @@ import { LogWithDecodedArgs, ZeroEx } from '0x.js'; -import { BlockchainLifecycle, RPC, web3Factory } from '@0xproject/dev-utils'; +import { BlockchainLifecycle, web3Factory } from '@0xproject/dev-utils'; import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; @@ -15,14 +15,12 @@ import { ContractName, SubmissionContractEventArgs } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; import { deployer } from './utils/deployer'; +import { web3, web3Wrapper } from './utils/web3_wrapper'; const MULTI_SIG_ABI = artifacts.MultiSigWalletWithTimeLockArtifact.networks[constants.TESTRPC_NETWORK_ID].abi; chaiSetup.configure(); const expect = chai.expect; - -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID }); const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]); @@ -39,11 +37,6 @@ describe('MultiSigWalletWithTimeLock', () => { let multiSigWrapper: MultiSigWrapper; let txId: BigNumber; let initialSecondsTimeLocked: number; - let rpc: RPC; - - before(async () => { - rpc = new RPC(); - }); beforeEach(async () => { await blockchainLifecycle.startAsync(); }); @@ -192,7 +185,7 @@ describe('MultiSigWalletWithTimeLock', () => { }); it('should execute if it has enough confirmations and is past the time lock', async () => { - await rpc.increaseTimeAsync(SECONDS_TIME_LOCKED.toNumber()); + await web3Wrapper.increaseTimeAsync(SECONDS_TIME_LOCKED.toNumber()); await multiSig.executeTransaction.sendTransactionAsync(txId, { from: owners[0] }); const secondsTimeLocked = new BigNumber(await multiSig.secondsTimeLocked.callAsync()); diff --git a/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts index c0299e1e1..6d20a67f3 100644 --- a/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts +++ b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts @@ -16,6 +16,7 @@ import { ContractName, SubmissionContractEventArgs, TransactionDataParams } from import { chaiSetup } from './utils/chai_setup'; import { deployer } from './utils/deployer'; +import { web3, web3Wrapper } from './utils/web3_wrapper'; const PROXY_ABI = artifacts.TokenTransferProxyArtifact.networks[constants.TESTRPC_NETWORK_ID].abi; const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI = artifacts.MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddressArtifact.networks[constants.TESTRPC_NETWORK_ID] @@ -23,9 +24,7 @@ const MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI = chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]); describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => { diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index eee14ad9f..9dcc77b82 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -14,12 +14,11 @@ import { ContractName } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; import { deployer } from './utils/deployer'; +import { web3, web3Wrapper } from './utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('TokenRegistry', () => { let owner: string; diff --git a/packages/contracts/test/token_transfer_proxy/auth.ts b/packages/contracts/test/token_transfer_proxy/auth.ts index 4f497dd0d..a1ccc6ff7 100644 --- a/packages/contracts/test/token_transfer_proxy/auth.ts +++ b/packages/contracts/test/token_transfer_proxy/auth.ts @@ -8,12 +8,11 @@ import { constants } from '../../util/constants'; import { ContractName } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; +import { web3, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('TokenTransferProxy', () => { let owner: string; diff --git a/packages/contracts/test/token_transfer_proxy/transfer_from.ts b/packages/contracts/test/token_transfer_proxy/transfer_from.ts index a77590288..415d068be 100644 --- a/packages/contracts/test/token_transfer_proxy/transfer_from.ts +++ b/packages/contracts/test/token_transfer_proxy/transfer_from.ts @@ -11,12 +11,11 @@ import { constants } from '../../util/constants'; import { ContractName } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; +import { web3, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('TokenTransferProxy', () => { let accounts: string[]; diff --git a/packages/contracts/test/tutorials/arbitrage.ts b/packages/contracts/test/tutorials/arbitrage.ts index 055fe9687..b2bbaf420 100644 --- a/packages/contracts/test/tutorials/arbitrage.ts +++ b/packages/contracts/test/tutorials/arbitrage.ts @@ -17,12 +17,11 @@ import { OrderFactory } from '../../util/order_factory'; import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; import { deployer } from '../utils/deployer'; +import { web3, web3Wrapper } from '../utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('Arbitrage', () => { let coinbase: string; diff --git a/packages/contracts/test/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts index 553178d80..c1c518adc 100644 --- a/packages/contracts/test/unlimited_allowance_token.ts +++ b/packages/contracts/test/unlimited_allowance_token.ts @@ -11,12 +11,11 @@ import { ContractName } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; import { deployer } from './utils/deployer'; +import { web3, web3Wrapper } from './utils/web3_wrapper'; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); chaiSetup.configure(); const expect = chai.expect; -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('UnlimitedAllowanceToken', () => { let owner: string; diff --git a/packages/contracts/test/utils/deployer.ts b/packages/contracts/test/utils/deployer.ts index 4e7f35c72..c1370f38c 100644 --- a/packages/contracts/test/utils/deployer.ts +++ b/packages/contracts/test/utils/deployer.ts @@ -4,7 +4,10 @@ import * as path from 'path'; import { constants } from '../../util/constants'; +import { web3 } from './web3_wrapper'; + const deployerOpts = { + web3Provider: web3.currentProvider, artifactsDir: path.resolve('src', 'artifacts'), jsonrpcPort: devConstants.RPC_PORT, networkId: constants.TESTRPC_NETWORK_ID, diff --git a/packages/contracts/test/utils/web3_wrapper.ts b/packages/contracts/test/utils/web3_wrapper.ts new file mode 100644 index 000000000..a8fe1532b --- /dev/null +++ b/packages/contracts/test/utils/web3_wrapper.ts @@ -0,0 +1,5 @@ +import { web3Factory } from '@0xproject/dev-utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; + +export const web3 = web3Factory.create(); +export const web3Wrapper = new Web3Wrapper(web3.currentProvider); diff --git a/packages/contracts/test/zrx_token.ts b/packages/contracts/test/zrx_token.ts index 4ccc66b36..a4cc3c2fc 100644 --- a/packages/contracts/test/zrx_token.ts +++ b/packages/contracts/test/zrx_token.ts @@ -11,12 +11,11 @@ import { ContractName } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; import { deployer } from './utils/deployer'; +import { web3, web3Wrapper } from './utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; -const web3 = web3Factory.create(); -const web3Wrapper = new Web3Wrapper(web3.currentProvider); -const blockchainLifecycle = new BlockchainLifecycle(); +const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); describe('ZRXToken', () => { let owner: string; |