Skip to content

Commit

Permalink
CI Coverage for Node (#26)
Browse files Browse the repository at this point in the history
* Fixing coverage in solidity tests
* Adding coverage workflow
  • Loading branch information
madhivedan committed Jul 22, 2022
1 parent ec1b539 commit d95992a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ jobs:
sub-filter-include: ${{ matrix.sub-filter-include }}
sub-filter-exclude: ${{ matrix.sub-filter-exclude }}

node-coverage:
runs-on: ubuntu-20.04
timeout-minutes: 60
defaults:
run:
working-directory: ./bridge
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: "bridge/.nvmrc"
cache: "npm"
cache-dependency-path: bridge/package-lock.json
- run: npm ci
- run: npm run clean
- run: npm run compile
- run: npx hardhat coverage --solcoverjs ./.solcover.ts
env:
NODE_OPTIONS: "--max_old_space_size=4096"

node-lint:
runs-on: ubuntu-20.04
timeout-minutes: 10
Expand Down
2 changes: 1 addition & 1 deletion bridge/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"require": "ts-node/register/files",
"timeout": 120000
"timeout": 240000
}
2 changes: 1 addition & 1 deletion bridge/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ const config: HardhatUserConfig = {
excludeContracts: ["*.t.sol"],
},
mocha: {
timeout: 120000,
timeout: 240000,
jobs: os.cpus().length / 2 > 1 ? os.cpus().length / 2 : 1,
},

Expand Down
4 changes: 3 additions & 1 deletion bridge/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,18 @@ export const createUsers = async (
numberOfUsers: number,
createWithNoFunds: boolean = false
): Promise<SignerWithAddress[]> => {
const hre: any = await require("hardhat");
const users: SignerWithAddress[] = [];
const admin = (await ethers.getSigners())[0];
for (let i = 0; i < numberOfUsers; i++) {
const user = new Wallet(Wallet.createRandom(), ethers.provider);
if (!createWithNoFunds) {
const balance = await ethers.provider.getBalance(user.address);
if (balance.eq(0)) {
const value = hre.__SOLIDITY_COVERAGE_RUNNING ? "1000000" : "1";
await admin.sendTransaction({
to: user.address,
value: ethers.utils.parseEther("1"),
value: ethers.utils.parseEther(value),
});
}
}
Expand Down

0 comments on commit d95992a

Please sign in to comment.