Skip to content

Commit

Permalink
Merge d34de28 into 7042ac7
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai committed Jan 31, 2020
2 parents 7042ac7 + d34de28 commit f5340ca
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -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",
Expand Down
36 changes: 14 additions & 22 deletions 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')
Expand All @@ -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
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -170,4 +162,4 @@ contract('DepositableDelegateProxy', ([ sender ]) => {
itForwardsToImplementationIfGasIsOverThreshold()
})
})
})
})
14 changes: 14 additions & 0 deletions 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
}
2 changes: 1 addition & 1 deletion truffle-config.js
@@ -1 +1 @@
module.exports = require('@aragon/truffle-config-v4/truffle-config')
module.exports = require('@aragon/truffle-config-v4')

0 comments on commit f5340ca

Please sign in to comment.