From 906af858a5b013927e06ebafdad12d13ba674932 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 7 May 2018 14:32:17 +0200 Subject: Fix artifacts paths --- packages/dev-utils/src/coverage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/dev-utils/src') diff --git a/packages/dev-utils/src/coverage.ts b/packages/dev-utils/src/coverage.ts index 67c87ec30..743573874 100644 --- a/packages/dev-utils/src/coverage.ts +++ b/packages/dev-utils/src/coverage.ts @@ -13,7 +13,7 @@ export const coverage = { return coverageSubprovider; }, _getCoverageSubprovider(): CoverageSubprovider { - const artifactsPath = '../migrations/src/artifacts'; + const artifactsPath = '../migrations/artifacts/1.0.0'; const contractsPath = 'src/contracts'; const networkId = 50; const defaultFromAddress = constants.TESTRPC_FIRST_ADDRESS; -- cgit v1.2.3 From 209266dbed9d7d038c90c2da8d9b99acab77c80c Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 9 May 2018 20:36:28 +0200 Subject: Split 0x.js into contract-wrappers, order-watcher but keep 0x.js as a unifying library with the same interface --- packages/dev-utils/src/callback_error_reporter.ts | 66 +++++++++++++++++++++++ packages/dev-utils/src/index.ts | 1 + 2 files changed, 67 insertions(+) create mode 100644 packages/dev-utils/src/callback_error_reporter.ts (limited to 'packages/dev-utils/src') diff --git a/packages/dev-utils/src/callback_error_reporter.ts b/packages/dev-utils/src/callback_error_reporter.ts new file mode 100644 index 000000000..874343ccc --- /dev/null +++ b/packages/dev-utils/src/callback_error_reporter.ts @@ -0,0 +1,66 @@ +import * as chai from 'chai'; +import * as _ from 'lodash'; + +import { DoneCallback } from '@0xproject/types'; + +const expect = chai.expect; + +export const callbackErrorReporter = { + reportNoErrorCallbackErrors(done: DoneCallback, expectToBeCalledOnce = true) { + return (f?: (value: T) => void) => { + const wrapped = (value: T) => { + if (_.isUndefined(f)) { + done(); + return; + } + try { + f(value); + if (expectToBeCalledOnce) { + done(); + } + } catch (err) { + done(err); + } + }; + return wrapped; + }; + }, + reportNodeCallbackErrors(done: DoneCallback, expectToBeCalledOnce = true) { + return (f?: (value: T) => void) => { + const wrapped = (error: Error | null, value: T | undefined) => { + if (!_.isNull(error)) { + done(error); + } else { + if (_.isUndefined(f)) { + done(); + return; + } + try { + f(value as T); + if (expectToBeCalledOnce) { + done(); + } + } catch (err) { + done(err); + } + } + }; + return wrapped; + }; + }, + assertNodeCallbackError(done: DoneCallback, errMsg: string) { + const wrapped = (error: Error | null, value: T | undefined) => { + if (_.isNull(error)) { + done(new Error('Expected callback to receive an error')); + } else { + try { + expect(error.message).to.be.equal(errMsg); + done(); + } catch (err) { + done(err); + } + } + }; + return wrapped; + }, +}; diff --git a/packages/dev-utils/src/index.ts b/packages/dev-utils/src/index.ts index 2ff2a2238..9124f3e28 100644 --- a/packages/dev-utils/src/index.ts +++ b/packages/dev-utils/src/index.ts @@ -3,3 +3,4 @@ export { web3Factory } from './web3_factory'; export { constants as devConstants } from './constants'; export { coverage } from './coverage'; export { env, EnvVars } from './env'; +export { callbackErrorReporter } from './callback_error_reporter'; -- cgit v1.2.3 From 13a61db2896074a939baa1769abef4c4917d4354 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 10 May 2018 15:22:51 +0200 Subject: Add var returns --- packages/dev-utils/src/callback_error_reporter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'packages/dev-utils/src') diff --git a/packages/dev-utils/src/callback_error_reporter.ts b/packages/dev-utils/src/callback_error_reporter.ts index 874343ccc..c8e693673 100644 --- a/packages/dev-utils/src/callback_error_reporter.ts +++ b/packages/dev-utils/src/callback_error_reporter.ts @@ -7,7 +7,7 @@ const expect = chai.expect; export const callbackErrorReporter = { reportNoErrorCallbackErrors(done: DoneCallback, expectToBeCalledOnce = true) { - return (f?: (value: T) => void) => { + const callback = (f?: (value: T) => void) => { const wrapped = (value: T) => { if (_.isUndefined(f)) { done(); @@ -24,9 +24,10 @@ export const callbackErrorReporter = { }; return wrapped; }; + return callback; }, reportNodeCallbackErrors(done: DoneCallback, expectToBeCalledOnce = true) { - return (f?: (value: T) => void) => { + const callback = (f?: (value: T) => void) => { const wrapped = (error: Error | null, value: T | undefined) => { if (!_.isNull(error)) { done(error); @@ -47,6 +48,7 @@ export const callbackErrorReporter = { }; return wrapped; }; + return callback; }, assertNodeCallbackError(done: DoneCallback, errMsg: string) { const wrapped = (error: Error | null, value: T | undefined) => { -- cgit v1.2.3 From 75d24dea0e10d098d3833488a420498410c22991 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 8 May 2018 16:02:04 +0200 Subject: Fix linter issues --- packages/dev-utils/src/coverage.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'packages/dev-utils/src') diff --git a/packages/dev-utils/src/coverage.ts b/packages/dev-utils/src/coverage.ts index 743573874..6f7640835 100644 --- a/packages/dev-utils/src/coverage.ts +++ b/packages/dev-utils/src/coverage.ts @@ -15,8 +15,7 @@ export const coverage = { _getCoverageSubprovider(): CoverageSubprovider { const artifactsPath = '../migrations/artifacts/1.0.0'; const contractsPath = 'src/contracts'; - const networkId = 50; const defaultFromAddress = constants.TESTRPC_FIRST_ADDRESS; - return new CoverageSubprovider(artifactsPath, contractsPath, networkId, defaultFromAddress); + return new CoverageSubprovider(artifactsPath, contractsPath, defaultFromAddress); }, }; -- cgit v1.2.3 From c093aab350dfbd86972d6388c3923ec60fc4501a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 11 May 2018 11:59:08 +0200 Subject: Fix ganache subprovider config --- packages/dev-utils/src/web3_factory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/dev-utils/src') diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 68348d671..4cd343c44 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -60,9 +60,9 @@ export const web3Factory = { provider.addProvider( new GanacheSubprovider({ logger, - verbose: env.parseBoolean(EnvVars.SolidityCoverage), + verbose: env.parseBoolean(EnvVars.VerboseGanache), port: 8545, - networkId: 50, + network_id: 50, mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic', }), ); -- cgit v1.2.3