diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-07-04 04:42:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-04 04:42:30 +0800 |
commit | d91b30faef0e53072757dfd5fea86db10dcf838f (patch) | |
tree | 5c48b7bdcec58668656d11e10cc3d8bee7680dac /packages/dev-utils | |
parent | 9b864517e2402d766b285098040787c62dfcd99d (diff) | |
parent | dc956020ef7c6d3f1880263700422b31253c8da3 (diff) | |
download | dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.tar dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.tar.gz dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.tar.bz2 dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.tar.lz dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.tar.xz dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.tar.zst dexon-sol-tools-d91b30faef0e53072757dfd5fea86db10dcf838f.zip |
Merge pull request #812 from 0xProject/fix/revert-assertions-improvements
Improve robustness of revert reason assertions
Diffstat (limited to 'packages/dev-utils')
-rw-r--r-- | packages/dev-utils/src/blockchain_lifecycle.ts | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/packages/dev-utils/src/blockchain_lifecycle.ts b/packages/dev-utils/src/blockchain_lifecycle.ts index 587332f1a..9bd65ee5d 100644 --- a/packages/dev-utils/src/blockchain_lifecycle.ts +++ b/packages/dev-utils/src/blockchain_lifecycle.ts @@ -1,11 +1,6 @@ import { logUtils } from '@0xproject/utils'; -import { uniqueVersionIds, Web3Wrapper } from '@0xproject/web3-wrapper'; -import { includes } from 'lodash'; - -enum NodeType { - Geth = 'GETH', - Ganache = 'GANACHE', -} +import { NodeType, Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; // HACK(albrow): 🐉 We have to do this so that debug.setHead works correctly. // (Geth does not seem to like debug.setHead(0), so by sending some transactions @@ -18,6 +13,7 @@ export class BlockchainLifecycle { private _web3Wrapper: Web3Wrapper; private _snapshotIdsStack: number[]; private _addresses: string[] = []; + private _nodeType: NodeType | undefined; constructor(web3Wrapper: Web3Wrapper) { this._web3Wrapper = web3Wrapper; this._snapshotIdsStack = []; @@ -61,16 +57,6 @@ export class BlockchainLifecycle { throw new Error(`Unknown node type: ${nodeType}`); } } - private async _getNodeTypeAsync(): Promise<NodeType> { - const version = await this._web3Wrapper.getNodeVersionAsync(); - if (includes(version, uniqueVersionIds.geth)) { - return NodeType.Geth; - } else if (includes(version, uniqueVersionIds.ganache)) { - return NodeType.Ganache; - } else { - throw new Error(`Unknown client version: ${version}`); - } - } private async _mineMinimumBlocksAsync(): Promise<void> { logUtils.warn('WARNING: minimum block number for tests not met. Mining additional blocks...'); if (this._addresses.length === 0) { @@ -92,4 +78,10 @@ export class BlockchainLifecycle { } logUtils.warn('Done mining the minimum number of blocks.'); } + private async _getNodeTypeAsync(): Promise<NodeType> { + if (_.isUndefined(this._nodeType)) { + this._nodeType = await this._web3Wrapper.getNodeTypeAsync(); + } + return this._nodeType; + } } |