From 6c02722f56dd37dd4237248e73d070755f86f318 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 4 Apr 2018 09:50:24 +0900 Subject: Make deployer tests run on inprocess ganache --- packages/deployer/package.json | 1 + packages/deployer/test/deployer_test.ts | 3 ++- packages/deployer/test/util/constants.ts | 1 - packages/deployer/test/util/provider.ts | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 packages/deployer/test/util/provider.ts (limited to 'packages/deployer') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index f6eff9973..97c2f15b1 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -47,6 +47,7 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/deployer/README.md", "devDependencies": { + "@0xproject/dev-utils": "^0.3.4", "@0xproject/monorepo-scripts": "^0.1.16", "@0xproject/tslint-config": "^0.4.14", "@types/require-from-string": "^1.2.0", diff --git a/packages/deployer/test/deployer_test.ts b/packages/deployer/test/deployer_test.ts index 9c34d74aa..eadb535ab 100644 --- a/packages/deployer/test/deployer_test.ts +++ b/packages/deployer/test/deployer_test.ts @@ -8,6 +8,7 @@ import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } import { constructor_args, exchange_binary } from './fixtures/exchange_bin'; import { constants } from './util/constants'; +import { provider } from './util/provider'; const expect = chai.expect; @@ -26,7 +27,7 @@ describe('#Deployer', () => { const deployerOpts = { artifactsDir, networkId: constants.networkId, - jsonrpcUrl: constants.jsonrpcUrl, + web3Provider: provider, defaults: { gasPrice: constants.gasPrice, }, diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts index 5385b8d17..b93081a80 100644 --- a/packages/deployer/test/util/constants.ts +++ b/packages/deployer/test/util/constants.ts @@ -2,7 +2,6 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { networkId: 0, - jsonrpcUrl: 'http://localhost:8545', optimizerEnabled: false, gasPrice: new BigNumber(20000000000), timeoutMs: 30000, diff --git a/packages/deployer/test/util/provider.ts b/packages/deployer/test/util/provider.ts new file mode 100644 index 000000000..bc0f55028 --- /dev/null +++ b/packages/deployer/test/util/provider.ts @@ -0,0 +1,6 @@ +import { web3Factory } from '@0xproject/dev-utils'; +import * as Web3 from 'web3'; + +const web3ProviderConfig = { shouldUseInProcessGanache: true }; +const web3Instance = web3Factory.create(web3ProviderConfig); +export const provider = web3Instance.currentProvider; -- cgit v1.2.3 From 20aaab0847d0ec8b2a44f392ddd467f0c475cfb5 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 4 Apr 2018 16:34:23 +0900 Subject: Add --exit to all mocha calls so they exit when called from top-level yarn command (https://github.com/mochajs/mocha/issues/3044) --- packages/deployer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/deployer') diff --git a/packages/deployer/package.json b/packages/deployer/package.json index 97c2f15b1..ad4ff30df 100644 --- a/packages/deployer/package.json +++ b/packages/deployer/package.json @@ -8,7 +8,7 @@ "build:watch": "tsc -w", "build": "yarn clean && copyfiles 'test/fixtures/contracts/**/*' ./lib && tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts", "test": "run-s build run_mocha", - "run_mocha": "mocha lib/test/*_test.js", + "run_mocha": "mocha lib/test/*_test.js --bail --exit", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", "compile": "npm run build; node lib/src/cli.js compile", -- cgit v1.2.3 From 75a51af00603236e0b80fe04336494944a32739c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 6 Apr 2018 15:04:17 +0900 Subject: Use provider over web3 in deployer, dev-utils and subprovider tests, rename subprovider to ganacheSubprovider in test util --- packages/deployer/src/cli.ts | 4 ++-- packages/deployer/src/deployer.ts | 10 +++++----- packages/deployer/test/deployer_test.ts | 2 +- packages/deployer/test/util/provider.ts | 9 ++++++--- 4 files changed, 14 insertions(+), 11 deletions(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/cli.ts b/packages/deployer/src/cli.ts index d1bd645b3..f1cf56416 100644 --- a/packages/deployer/src/cli.ts +++ b/packages/deployer/src/cli.ts @@ -41,8 +41,8 @@ async function onCompileCommandAsync(argv: CliOptions): Promise { */ async function onDeployCommandAsync(argv: CliOptions): Promise { const url = argv.jsonrpcUrl; - const web3Provider = new Web3.providers.HttpProvider(url); - const web3Wrapper = new Web3Wrapper(web3Provider); + const provider = new Web3.providers.HttpProvider(url); + const web3Wrapper = new Web3Wrapper(provider); const networkId = await web3Wrapper.getNetworkIdAsync(); const compilerOpts: CompilerOptions = { contractsDir: argv.contractsDir, diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts index 84392997c..e4208e7a1 100644 --- a/packages/deployer/src/deployer.ts +++ b/packages/deployer/src/deployer.ts @@ -38,17 +38,17 @@ export class Deployer { this._artifactsDir = opts.artifactsDir; this._networkId = opts.networkId; this._defaults = opts.defaults; - let web3Provider: Provider; + let provider: Provider; if (_.isUndefined((opts as ProviderDeployerOptions).provider)) { const jsonrpcUrl = (opts as UrlDeployerOptions).jsonrpcUrl; if (_.isUndefined(jsonrpcUrl)) { - throw new Error(`Deployer options don't contain web3Provider nor jsonrpcUrl. Please pass one of them`); + throw new Error(`Deployer options don't contain provider nor jsonrpcUrl. Please pass one of them`); } - web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl); + provider = new Web3.providers.HttpProvider(jsonrpcUrl); } else { - web3Provider = (opts as ProviderDeployerOptions).provider; + provider = (opts as ProviderDeployerOptions).provider; } - this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults); + this.web3Wrapper = new Web3Wrapper(provider, this._defaults); } /** * Loads a contract's corresponding artifacts and deploys it with the supplied constructor arguments. diff --git a/packages/deployer/test/deployer_test.ts b/packages/deployer/test/deployer_test.ts index eadb535ab..238624220 100644 --- a/packages/deployer/test/deployer_test.ts +++ b/packages/deployer/test/deployer_test.ts @@ -27,7 +27,7 @@ describe('#Deployer', () => { const deployerOpts = { artifactsDir, networkId: constants.networkId, - web3Provider: provider, + provider, defaults: { gasPrice: constants.gasPrice, }, diff --git a/packages/deployer/test/util/provider.ts b/packages/deployer/test/util/provider.ts index bc0f55028..e0fcb362a 100644 --- a/packages/deployer/test/util/provider.ts +++ b/packages/deployer/test/util/provider.ts @@ -1,6 +1,9 @@ import { web3Factory } from '@0xproject/dev-utils'; +import { Provider } from '@0xproject/types'; import * as Web3 from 'web3'; -const web3ProviderConfig = { shouldUseInProcessGanache: true }; -const web3Instance = web3Factory.create(web3ProviderConfig); -export const provider = web3Instance.currentProvider; +const providerConfigs = { shouldUseInProcessGanache: true }; +const web3Instance = web3Factory.create(providerConfigs); +const provider: Provider = web3Instance.currentProvider; + +export { provider }; -- cgit v1.2.3 From 3c84ce205000e9268163c4a15bc0753f566ccd56 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 11 Apr 2018 22:37:39 +0900 Subject: Improve deployer error message --- packages/deployer/src/deployer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/deployer') diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts index e4208e7a1..ad05417b1 100644 --- a/packages/deployer/src/deployer.ts +++ b/packages/deployer/src/deployer.ts @@ -170,7 +170,7 @@ export class Deployer { const contractArtifact: ContractArtifact = require(artifactPath); return contractArtifact; } catch (err) { - throw new Error(`Artifact not found for contract: ${contractName}`); + throw new Error(`Artifact not found for contract: ${contractName} at ${artifactPath}`); } } /** -- cgit v1.2.3