Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Fix coverage task #614

Merged
merged 6 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
const skipFiles = [
'lib',
'test',
'acl/ACLSyntaxSugar.sol',
'common/DepositableStorage.sol', // Used in tests that send ETH
'common/UnstructuredStorage.sol' // Used in tests that send ETH
]

module.exports = {
norpc: true,
compileCommand: '../node_modules/.bin/truffle compile',
testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage',
skipFiles,
skipFiles: [
'lib',
'test',
'acl/ACLSyntaxSugar.sol',
],
mocha: {
grep: '@skip-on-coverage', // Find everything with this tag
invert: true // Run the grep's inverse set.
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:gas": "GAS_REPORTER=true npm test",
"test:gas:ci": "yarn test:gas && npx codechecks",
"test:ganache-cli": "./node_modules/@aragon/contract-helpers-test/scripts/ganache-cli.sh",
"coverage": "SOLIDITY_COVERAGE=true yarn test:ganache-cli",
"coverage": "npx truffle run coverage",
"abi:extract": "truffle-extract --output abi/ --keys abi",
"bytecode:extract": "truffle-bytecode extract -o bytecode",
"bytecode:extract:new": "truffle-bytecode extract -o bytecode_new",
Expand Down
3 changes: 1 addition & 2 deletions test/contracts/acl/acl_params.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { assertRevert } = require('@aragon/contract-helpers-test/src/asserts')
const { skipSuiteCoverage } = require('../../helpers/coverage')
const { permissionParamEqOracle } = require('../../helpers/permissionParams')

const ACL = artifacts.require('ACL')
Expand Down Expand Up @@ -118,7 +117,7 @@ contract('ACL params', ([permissionsRoot, specificEntity, noPermission, mockAppA
['asserts', AssertOracle],
['uses all available gas', OverGasLimitOracle],
]) {
skipSuiteCoverage(describe)(`when the oracle ${description}`, () => {
describe(`when the oracle ${description} [@skip-on-coverage]`, () => {
let overGasLimitOracle

before(async () => {
Expand Down
6 changes: 3 additions & 3 deletions test/contracts/apps/recovery_to_vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ contract('Recovery to vault', ([permissionsRoot]) => {
await assertRevert(target.sendTransaction({ value: 1, data: '0x01', gas: SEND_ETH_GAS }))
})

it('recovers ETH', async () =>
it('recovers ETH [@skip-on-coverage]', async () => {
await recoverEth({ target, vault })
)
})

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

it('recovers ETH from the kernel', async () => {
it('recovers ETH from the kernel [@skip-on-coverage]', async () => {
await recoverEth({ target: kernel, vault })
})
})
Expand Down
26 changes: 10 additions & 16 deletions test/contracts/common/depositable_delegate_proxy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { skipCoverage } = require('../../helpers/coverage')
const { bn } = require('@aragon/contract-helpers-test')
const { assertAmountOfEvents, assertEvent, assertRevert, assertOutOfGas, assertBn } = require('@aragon/contract-helpers-test/src/asserts')

Expand All @@ -11,7 +10,7 @@ const ProxyTargetWithFallback = artifacts.require('ProxyTargetWithFallback')
const TX_BASE_GAS = 21000
const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for depositing
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 FALLBACK_SETUP_GAS = 100 // rough estimation of how much gas it spends before executing the fallback code
const SOLIDITY_TRANSFER_GAS = 2300

contract('DepositableDelegateProxy', ([ sender ]) => {
Expand Down Expand Up @@ -45,7 +44,7 @@ contract('DepositableDelegateProxy', ([ sender ]) => {

itSuccessfullyForwardsCall()

it('can receive ETH', async () => {
it('can receive ETH [@skip-on-coverage]', async () => {
const receipt = await target.sendTransaction({ value: 1, gas: SEND_ETH_GAS + FALLBACK_SETUP_GAS })
assertAmountOfEvents(receipt, 'ReceivedEth')
})
Expand Down Expand Up @@ -115,22 +114,17 @@ contract('DepositableDelegateProxy', ([ sender ]) => {
}

it('can receive ETH', async () => {
const { gasUsed } = await assertSendEthToProxy({ value, gas: SEND_ETH_GAS })
await assertSendEthToProxy({ value, gas: SEND_ETH_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('cannot receive ETH if sent with a small amount of gas [@skip-on-coverage]', 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 () => {
it('can receive ETH from contract [@skip-on-coverage]', async () => {
const receipt = await ethSender.sendEth(proxy.address, { value })

assertAmountOfEvents(receipt, 'ProxyDeposit', { decodeForAbi: proxy.abi })
Expand Down
20 changes: 0 additions & 20 deletions test/helpers/coverage.js

This file was deleted.