Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Add coverage

* Use coverage in CI

* Use type import

Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>

* Add explanation for skipping E2E tests

* Bump solidity-coverage to v0.7.15

* Add Coveralls

Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
  • Loading branch information
fedgiac and nlordell authored Feb 23, 2021
1 parent a3280cd commit b27e642
Show file tree
Hide file tree
Showing 8 changed files with 535 additions and 95 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Node.js CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:

jobs:
Expand All @@ -28,4 +28,9 @@ jobs:
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn lint
- run: yarn test
- run: yarn coverage
- run: yarn test:ignored-in-coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
build/
coverage/
deployments/*/solcInputs
node_modules/
lib/
node_modules/
coverage.json
yarn-error.log
*.tgz
3 changes: 3 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
skipFiles: ["test/"],
};
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ yarn verify --network $NETWORK

This package additionally contains a `networks.json` file at the root with the address of each deployed contract as well the hash of the Ethereum transaction used to create the contract.

## Test coverage [![Coverage Status](https://coveralls.io/repos/github/gnosis/gp-v2-contracts/badge.svg?branch=main)](https://coveralls.io/github/gnosis/gp-v2-contracts?branch=main)

Test coverage can be checked with the command

```sh
yarn coverage
```

A summary of coverage results are printed out to console. More detailed information is presented in the generated file `coverage/index.html`.

### Solver Authentication

This repo contains scripts to manage the list of authenticated solvers in all networks the contract has been deployed.
Expand Down
24 changes: 23 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import "@nomiclabs/hardhat-waffle";
import "hardhat-deploy";
import "hardhat-gas-reporter";
import "solidity-coverage";

import dotenv from "dotenv";
import type { HttpNetworkUserConfig } from "hardhat/types";
import type { MochaOptions } from "mocha";
import yargs from "yargs";

import { setupSolversTask } from "./src/tasks/solvers";
Expand All @@ -18,7 +20,7 @@ const argv = yargs

// Load environment variables.
dotenv.config();
const { INFURA_KEY, MNEMONIC, PK, REPORT_GAS } = process.env;
const { INFURA_KEY, MNEMONIC, PK, REPORT_GAS, MOCHA_CONF } = process.env;

const DEFAULT_MNEMONIC =
"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
Expand All @@ -38,9 +40,29 @@ if (["rinkeby", "mainnet"].includes(argv.network) && INFURA_KEY === undefined) {
);
}

const mocha: MochaOptions = {};
switch (MOCHA_CONF) {
case undefined:
break;
case "coverage":
// End to end tests are skipped because:
// - coverage tool does not play well with proxy deployment with
// hardhat-deploy
// - coverage compiles without optimizer and, unlike Waffle, hardhat-deploy
// strictly enforces the contract size limits from EIP-170
mocha.grep = /^(?!E2E)/;
break;
case "ignored in coverage":
mocha.grep = /^E2E/;
break;
default:
throw new Error("Invalid MOCHA_CONF");
}

setupSolversTask();

export default {
mocha,
paths: {
artifacts: "build/artifacts",
cache: "build/cache",
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"verify": "hardhat etherscan-verify --license LGPL-3.0 --force-license",
"solvers": "hardhat solvers",
"test": "hardhat test",
"test:ignored-in-coverage": "MOCHA_CONF='ignored in coverage' hardhat test",
"coverage": "MOCHA_CONF='coverage' hardhat coverage",
"bench": "hardhat run bench/index.ts",
"bench:compare": "bash bench/compare.sh",
"bench:single": "hardhat run bench/single.ts",
Expand Down Expand Up @@ -56,6 +58,7 @@
"prettier-plugin-solidity": "^1.0.0-beta.5",
"solhint": "^3.3.2",
"solhint-plugin-prettier": "^0.0.5",
"solidity-coverage": "^0.7.15",
"ts-node": "^9.1.1",
"typescript": "^4.1.5",
"yargs": "^16.2.0"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/upgradeAuthenticator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function upgrade(
});
}

describe("Upgrade Authenticator", () => {
describe("E2E: Upgrade Authenticator", () => {
let authenticator: Contract;
let deployer: Wallet;
let owner: Wallet;
Expand Down
Loading

0 comments on commit b27e642

Please sign in to comment.