diff --git a/package-lock.json b/package-lock.json index fd2f2ac70..b5ce5da27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2403,6 +2403,14 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "rimraf": "^2.2.8" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "delayed-stream": { @@ -2870,6 +2878,14 @@ "parse-json": "^2.2.0", "pify": "^2.0.0", "strip-bom": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "path-type": { @@ -2879,6 +2895,14 @@ "dev": true, "requires": { "pify": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "read-pkg": { @@ -4748,6 +4772,14 @@ "object-assign": "^4.0.1", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "graceful-fs": { @@ -5937,6 +5969,14 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "strip-bom": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "loader-utils": { @@ -6966,6 +7006,14 @@ "graceful-fs": "^4.1.2", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "pathval": { @@ -6987,9 +7035,9 @@ "dev": true }, "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true }, "pinkie": { @@ -8927,6 +8975,14 @@ "strip-bom": "^2.0.0", "strip-bom-stream": "^2.0.0", "vinyl": "^1.1.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "web3": { diff --git a/package.json b/package.json index 2c65ee66b..fa030dfc5 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "ethereumjs-util": "^6.0.0", "ethjs-abi": "^0.2.1", "ganache-cli": "6.1.8", + "pify": "^4.0.1", "solidity-coverage": "^0.5.4", "solium": "^1.1.8", "truffle": "^4.1.13", diff --git a/test/helpers/balanceDifference.js b/test/helpers/balanceDifference.js index 883d7df49..e514b0160 100644 --- a/test/helpers/balanceDifference.js +++ b/test/helpers/balanceDifference.js @@ -1,7 +1,9 @@ +const { ethGetBalance } = require('./web3'); + async function balanceDifference (account, promiseFunc) { - const balanceBefore = web3.eth.getBalance(account); + const balanceBefore = await ethGetBalance(account); await promiseFunc(); - const balanceAfter = web3.eth.getBalance(account); + const balanceAfter = await ethGetBalance(account); return balanceAfter.minus(balanceBefore); } diff --git a/test/helpers/expectEvent.js b/test/helpers/expectEvent.js index 690a09979..3cb6b37ec 100644 --- a/test/helpers/expectEvent.js +++ b/test/helpers/expectEvent.js @@ -1,4 +1,5 @@ const SolidityEvent = require('web3/lib/web3/event.js'); +const { ethGetTransactionReceipt } = require('./web3'); const BigNumber = web3.BigNumber; const should = require('chai') @@ -23,7 +24,7 @@ async function inConstruction (contract, eventName, eventArgs = {}) { } async function inTransaction (txHash, emitter, eventName, eventArgs = {}) { - const receipt = await web3.eth.getTransactionReceipt(txHash); + const receipt = await ethGetTransactionReceipt(txHash); const logs = decodeLogs(receipt.logs, emitter.events); return inLogs(logs, eventName, eventArgs); diff --git a/test/helpers/time.js b/test/helpers/time.js index 727250831..c8c844079 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -1,8 +1,8 @@ const { ethGetBlock } = require('./web3'); -const { promisify } = require('util'); +const pify = require('pify'); function advanceBlock () { - return promisify(web3.currentProvider.sendAsync)({ + return pify(web3.currentProvider.sendAsync)({ jsonrpc: '2.0', method: 'evm_mine', }); @@ -18,7 +18,7 @@ async function latest () { async function increase (duration) { if (duration < 0) throw Error(`Cannot increase time by a negative amount (${duration})`); - await promisify(web3.currentProvider.sendAsync)({ + await pify(web3.currentProvider.sendAsync)({ jsonrpc: '2.0', method: 'evm_increaseTime', params: [duration], diff --git a/test/helpers/web3.js b/test/helpers/web3.js index b4fd87199..b6cd493e1 100644 --- a/test/helpers/web3.js +++ b/test/helpers/web3.js @@ -4,6 +4,7 @@ const ethAsync = pify(web3.eth); module.exports = { ethGetBalance: ethAsync.getBalance, - ethSendTransaction: ethAsync.sendTransaction, ethGetBlock: ethAsync.getBlock, + ethGetTransactionReceipt: ethAsync.getTransactionReceipt, + ethSendTransaction: ethAsync.sendTransaction, };