From fb93deed849393c5436fa3a57bbf2007487089e5 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Sat, 1 Feb 2020 00:46:41 +0100 Subject: [PATCH] chore: Update to Istanbul context (#568) * chore: update devDependencies * test: update for istanbul context --- package.json | 12 +++---- .../common/depositable_delegate_proxy.js | 36 ++++++++----------- test/helpers/coverage.js | 14 ++++++++ truffle-config.js | 2 +- 4 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 test/helpers/coverage.js diff --git a/package.json b/package.json index e57f250f7..dde41a33d 100644 --- a/package.json +++ b/package.json @@ -34,21 +34,21 @@ "repository": "https://github.com/aragon/aragonOS", "license": "(GPL-3.0-or-later OR MIT)", "devDependencies": { - "@aragon/truffle-config-v4": "^1.0.0", + "@aragon/truffle-config-v4": "^1.0.1", "@codechecks/client": "^0.1.5", - "coveralls": "^2.13.3", + "coveralls": "^3.0.9", "eth-ens-namehash": "^2.0.8", - "eth-gas-reporter": "^0.2.9", + "eth-gas-reporter": "^0.2.14", "ethereumjs-abi": "^0.6.5", - "ganache-cli": "^6.4.2", + "ganache-cli": "^6.9.0", "mocha-lcov-reporter": "^1.3.0", "solidity-coverage": "0.6.2", "solium": "^1.2.3", "truffle": "4.1.14", "truffle-bytecode-manager": "^1.1.1", "truffle-extract": "^1.2.1", - "web3-eth-abi": "1.0.0-beta.33", - "web3-utils": "1.0.0-beta.33" + "web3-eth-abi": "1.2.5", + "web3-utils": "1.2.5" }, "dependencies": { "mkdirp": "^0.5.1", diff --git a/test/contracts/common/depositable_delegate_proxy.js b/test/contracts/common/depositable_delegate_proxy.js index c05231b3a..07ce0537e 100644 --- a/test/contracts/common/depositable_delegate_proxy.js +++ b/test/contracts/common/depositable_delegate_proxy.js @@ -1,5 +1,6 @@ const { toChecksumAddress } = require('web3-utils') const { assertAmountOfEvents, assertEvent } = require('../../helpers/assertEvent')(web3) +const { skipCoverage } = require('../../helpers/coverage') const { decodeEventsOfType } = require('../../helpers/decodeEvent') const { assertRevert, assertOutOfGas } = require('../../helpers/assertThrow') const { getBalance } = require('../../helpers/web3') @@ -15,7 +16,6 @@ const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for deposit const PROXY_FORWARD_GAS = TX_BASE_GAS + 2e6 // high gas amount to ensure that the proxy forwards the call const FALLBACK_SETUP_GAS = process.env.SOLIDITY_COVERAGE ? 5000 : 100 // rough estimation of how much gas it spends before executing the fallback code const SOLIDITY_TRANSFER_GAS = 2300 -const ISTANBUL_SLOAD_GAS_INCREASE = 600 contract('DepositableDelegateProxy', ([ sender ]) => { let ethSender, proxy, target, proxyTargetWithoutFallbackBase, proxyTargetWithFallbackBase @@ -117,29 +117,21 @@ contract('DepositableDelegateProxy', ([ sender ]) => { } } - it('can receive ETH (Constantinople)', async () => { + it('can receive ETH', async () => { const { gasUsed } = await assertSendEthToProxy({ value, gas: SEND_ETH_GAS }) - console.log('Used gas:', gasUsed - TX_BASE_GAS) }) - // TODO: Remove when the targetted EVM has been upgraded to Istanbul (EIP-1884) - it('can receive ETH (Istanbul, EIP-1884)', async () => { - const gas = TX_BASE_GAS + SOLIDITY_TRANSFER_GAS - ISTANBUL_SLOAD_GAS_INCREASE - const { gasUsed } = await assertSendEthToProxy({ value, gas }) - const gasUsedIstanbul = gasUsed - TX_BASE_GAS + ISTANBUL_SLOAD_GAS_INCREASE - console.log('Used gas (Istanbul):', gasUsedIstanbul) - - assert.isBelow(gasUsedIstanbul, 2300, 'Gas cost under Istanbul cannot be above 2300 gas') - }) - - // TODO: Remove when the targetted EVM has been upgraded to Istanbul (EIP-1884) - it('cannot receive ETH if sent with a small amount of gas', async () => { - // solidity-coverage seems to be increasing the gas amount to prevent failures - const oogDecrease = process.env.SOLIDITY_COVERAGE ? 600 : 250 - // deposit cannot be done with this amount of gas - const gas = TX_BASE_GAS + SOLIDITY_TRANSFER_GAS - ISTANBUL_SLOAD_GAS_INCREASE - oogDecrease - await assertSendEthToProxy({ shouldOOG: true, value, gas }) - }) + it( + 'cannot receive ETH if sent with a small amount of gas', + // Our version of solidity-coverage is not on an istanbul context yet + // TODO: update solidity-coverage + skipCoverage(async () => { + const oogDecrease = 250 + // deposit cannot be done with this amount of gas + const gas = TX_BASE_GAS + SOLIDITY_TRANSFER_GAS - oogDecrease + await assertSendEthToProxy({ shouldOOG: true, value, gas }) + }) + ) it('can receive ETH from contract', async () => { const { tx } = await ethSender.sendEth(proxy.address, { value }) @@ -170,4 +162,4 @@ contract('DepositableDelegateProxy', ([ sender ]) => { itForwardsToImplementationIfGasIsOverThreshold() }) }) -}) \ No newline at end of file +}) diff --git a/test/helpers/coverage.js b/test/helpers/coverage.js new file mode 100644 index 000000000..f5f313242 --- /dev/null +++ b/test/helpers/coverage.js @@ -0,0 +1,14 @@ +const skipCoverage = test => { + // Required dynamic this binding to attach onto the running test + return function skipCoverage() { + if (process.env.SOLIDITY_COVERAGE === 'true') { + this.skip() + } else { + return test() + } + } +} + +module.exports = { + skipCoverage +} diff --git a/truffle-config.js b/truffle-config.js index c37505f04..31f7ad982 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -1 +1 @@ -module.exports = require('@aragon/truffle-config-v4/truffle-config') \ No newline at end of file +module.exports = require('@aragon/truffle-config-v4')