Skip to content

Commit

Permalink
chore: upgrade solidity-coverage to v0.6+ (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
sohkai committed Jul 15, 2019
1 parent c85d34e commit fbf0fad
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 39 deletions.
1 change: 0 additions & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const skipFiles = [
'test',
'acl/ACLSyntaxSugar.sol',
'common/DepositableStorage.sol', // Used in tests that send ETH
'common/SafeERC20.sol', // solidity-coverage fails on assembly if (https://github.com/sc-forks/solidity-coverage/issues/287)
'common/UnstructuredStorage.sol' // Used in tests that send ETH
]

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ethereumjs-abi": "^0.6.5",
"ganache-cli": "^6.4.2",
"mocha-lcov-reporter": "^1.3.0",
"solidity-coverage": "0.5.8",
"solidity-coverage": "^0.6.2",
"solium": "^1.2.3",
"truffle": "4.1.14",
"truffle-bytecode-manager": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/apps/app_funds.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { hash } = require('eth-ens-namehash')
const { onlyIf } = require('../../helpers/onlyIf')
const { getBalance } = require('../../helpers/web3')
const { assertRevert } = require('../../helpers/assertThrow')
const { getBalance } = require('../../helpers/web3')

const ACL = artifacts.require('ACL')
const Kernel = artifacts.require('Kernel')
Expand Down
30 changes: 10 additions & 20 deletions test/contracts/apps/recovery_to_vault.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const { hash } = require('eth-ens-namehash')
const { getBalance } = require('../../helpers/web3')
const { skipCoverage } = require('../../helpers/coverage')
const { assertAmountOfEvents, assertEvent } = require('../../helpers/assertEvent')(web3)
const { assertRevert } = require('../../helpers/assertThrow')
const { getNewProxyAddress } = require('../../helpers/events')
const { assertAmountOfEvents, assertEvent } = require('../../helpers/assertEvent')(web3)
const { getBalance } = require('../../helpers/web3')

const ACL = artifacts.require('ACL')
const Kernel = artifacts.require('Kernel')
Expand Down Expand Up @@ -160,15 +159,6 @@ contract('Recovery to vault', ([permissionsRoot]) => {

// Test both the Vault itself and when it's behind a proxy to make sure their recovery behaviours are the same
for (const vaultType of ['Vault', 'VaultProxy']) {
const skipCoverageIfVaultProxy = test => {
// The VaultMock isn't instrumented during coverage, but the AppProxy is, and so
// transferring to the fallback fails when we're testing with the proxy.
// Native transfers (either .send() or .transfer()) fail under coverage because they're
// limited to 2.3k gas, and the injected instrumentation from coverage makes these
// operations cost more than that limit.
return vaultType === 'VaultProxy' ? skipCoverage(test) : test
}

context(`> ${vaultType}`, () => {
let target, vault

Expand Down Expand Up @@ -218,9 +208,9 @@ contract('Recovery to vault', ([permissionsRoot]) => {
await target.enableDeposits()
})

it('does not recover ETH', skipCoverageIfVaultProxy(async () =>
it('does not recover ETH', async () =>
await recoverEth({ target, vault, shouldFail: true })
))
)

it('does not recover tokens', async () =>
await recoverTokens({
Expand Down Expand Up @@ -251,9 +241,9 @@ contract('Recovery to vault', ([permissionsRoot]) => {
await assertRevert(target.sendTransaction({ value: 1, data: '0x01', gas: SEND_ETH_GAS }))
})

it('recovers ETH', skipCoverageIfVaultProxy(async () =>
it('recovers ETH', async () =>
await recoverEth({ target, vault })
))
)

for (const { title, tokenContract } of tokenTestGroups) {
it(`recovers ${title}`, async () => {
Expand Down Expand Up @@ -289,10 +279,10 @@ contract('Recovery to vault', ([permissionsRoot]) => {
target = app
})

it('does not allow recovering ETH', skipCoverageIfVaultProxy(async () =>
it('does not allow recovering ETH', async () =>
// Conditional stub doesnt allow eth recoveries
await recoverEth({ target, vault, shouldFail: true })
))
)

for (const { title, tokenContract } of tokenTestGroups) {
it(`allows recovers ${title}`, async () => {
Expand Down Expand Up @@ -344,8 +334,8 @@ contract('Recovery to vault', ([permissionsRoot]) => {
await kernel.setRecoveryVaultAppId(vaultId)
})

it('recovers ETH from the kernel', skipCoverage(async () => {
it('recovers ETH from the kernel', async () => {
await recoverEth({ target: kernel, vault })
}))
})
})
})
2 changes: 1 addition & 1 deletion test/contracts/kernel/kernel_funds.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { assertRevert } = require('../../helpers/assertThrow')
const { onlyIf } = require('../../helpers/onlyIf')
const { getBalance } = require('../../helpers/web3')
const { assertRevert } = require('../../helpers/assertThrow')

const ACL = artifacts.require('ACL')
const Kernel = artifacts.require('Kernel')
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/assertThrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
error.reason = error.message.replace(errorPrefix, '').trim()
}

if (process.env.SOLIDITY_COVERAGE !== 'true' && reason) {
if (reason) {
assert.equal(error.reason, reason, `Expected revert reason "${reason}" but failed with "${error.reason || 'no reason'}" instead.`)
}
},
Expand Down
14 changes: 0 additions & 14 deletions test/helpers/coverage.js

This file was deleted.

0 comments on commit fbf0fad

Please sign in to comment.