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

[WIP] Upgrade solidity-coverage to 0.7.0-beta #716

Closed
Closed
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
28 changes: 23 additions & 5 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
const { execSync } = require("child_process");
const log = console.log;

// Copies pre-built token artifacts to .coverage_artifacts/contracts
function provisionTokenContracts(config){
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This token provisioning is now done in a post-compilation hook executed by the Truffle plugin. You're also usually compiling the DappSys contracts during this step but Truffle kept reporting there was nothing to compile there, so I just skipped that. But if it's necessary it would go in this function...

let output;
const provisionColonyToken = `bash ./scripts/provision-token-contracts.sh`;

log('Provisioning ColonyToken contracts...')
output = execSync(provisionColonyToken);
log(output.toString())
}

module.exports = {
skipFiles: [
'Migrations.sol',
Expand All @@ -7,8 +20,13 @@ module.exports = {
'testHelpers/NoLimitSubdomains',
'testHelpers/TaskSkillEditing'
],
copyPackages: ['openzeppelin-solidity'],
compileCommand: 'yarn run provision:token:contracts',
testCommand: '../node_modules/.bin/truffle test --network coverage',
testrpcOptions: `--port 8555 -i 1999 --acctKeys="./coverageEnv/ganache-accounts.json" --noVMErrorsOnRPCResponse --accounts 12 --allowUnlimitedContractSize`
};
providerOptions: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all the flags passed to testrc-sc, translated to ganache-core options and passed to ganache.

port: 8555,
network_id: 1999,
account_keys_path: "./ganache-accounts.json",
vmErrorsOnRPCResponse: false,
total_accounts: 12
},
onCompileComplete: provisionTokenContracts
}

3 changes: 1 addition & 2 deletions helpers/upgradable-contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function setupEtherRouter(interfaceContract, deployedImplementation
const fName = value.name;
const fType = value.type;
// These are from DSAuth, and so are on EtherRouter itself without any more help.
if (fName !== "authority" && fName !== "owner") {
if (fName !== "authority" && fName !== "owner" && !fName.includes("coverage_")) {
Copy link
Collaborator Author

@cgewecke cgewecke Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instrumentation is now done using an injected public function (instead of an event) and it needs to be excluded here.

// We only care about functions.
if (fType === "function") {
// Gets the types of the parameters, which is all we care about for function signatures.
Expand Down Expand Up @@ -92,7 +92,6 @@ export async function setupUpgradableColonyNetwork(
deployedImplementations.ContractRecovery = contractRecovery.address;

await setupEtherRouter("IColonyNetwork", deployedImplementations, resolver);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mistake.

await etherRouter.setResolver(resolver.address);
}

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"test:contracts:upgrade:2to3": "npm run start:blockchain:client:2to3 & truffle test ./test-upgrade/2to3/2to3.js",
"test:contracts:gasCosts": "npm run start:blockchain:client & truffle migrate --reset --compile-all && truffle test test-gas-costs/gasCosts.js --network development",
"test:contracts:patricia": "npm run start:blockchain:client parity & truffle migrate --reset --compile-all && truffle test packages/reputation-miner/patricia-test.js --network development",
"test:contracts:coverage": "SOLIDITY_COVERAGE=1 solidity-coverage && istanbul check-coverage --statements 99 --branches 94 --functions 99 --lines 99",
"test:contracts:coverage": "SOLIDITY_COVERAGE=1 truffle run coverage --network coverage --temp build && istanbul check-coverage --statements 99 --branches 94 --functions 99 --lines 99",
Copy link
Collaborator Author

@cgewecke cgewecke Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There something important here: --temp build means: "write the temporary coverage compilation artifacts to build". It treats that folder as disposable and will delete it after coverage runs. Normally we would use a folder called .coverage_artifacts but there are many places in the test setup scripts where the artifacts are explicitly requested from build.

In <= 0.6.x the whole project gets copied into a sub-folder. That works well here but has been the source of quite a bit of weirdness elsewhere :) In the plugin version, the contracts/artifacts are written to temp folders at the root and truffle's path variables are re-targeted to use them as sources for compilation and testing.

"test:contracts:watch": "npm run start:blockchain:client & truffle migrate --reset --compile-all && truffle watch --network development",
"test:contracts:e2e": "npm run start:blockchain:client & truffle migrate --reset --compile-all && truffle test test-system/end-to-end.js --network development",
"test:security:slither": "slither contracts/ --solc-disable-warnings --exclude-low --exclude-informational --exclude uninitialized-state-variables,uninitialized-local-variables,reentrancy-no-eth",
Expand Down Expand Up @@ -108,10 +108,10 @@
"prettier": "^1.18.0",
"rimraf": "^3.0.0",
"shortid": "^2.2.14",
"solidity-coverage": "^0.6.0",
"solidity-coverage": "0.7.0-beta.2",
"solidity-parser-antlr": "^0.4.5",
"solidity-steamroller": "^1.1.0",
"truffle": "^5.0.14",
"truffle": "^5.0.37",
"truffle-hdwallet-provider": "^1.0.9",
"truffle-security": "^1.5.2",
"web3-utils": "^1.0.0"
Expand Down
6 changes: 2 additions & 4 deletions truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ module.exports = {
},
coverage: {
host: "localhost",
port: 8555, // <-- Use port 8555
gas: 0xfffffffffff, // <-- Use this high gas value
gasPrice: 0x01, // <-- Use this low gas price
port: 8555,
network_id: 1999,
skipDryRun: true
},
Expand Down Expand Up @@ -74,5 +72,5 @@ module.exports = {
}
}
},
plugins: ["truffle-security"]
plugins: ["truffle-security", "solidity-coverage"]
};
Loading