Skip to content

Commit

Permalink
fix typechain coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Sep 19, 2024
1 parent be6b087 commit 86899fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion packages/contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@ import '@openzeppelin/hardhat-upgrades';
import * as dotenv from 'dotenv';
import 'hardhat-deploy';
import 'hardhat-gas-reporter';
import {extendEnvironment, HardhatUserConfig} from 'hardhat/config';
import {extendEnvironment, HardhatUserConfig, task} from 'hardhat/config';
import type {NetworkUserConfig} from 'hardhat/types';
import 'solidity-coverage';
import 'solidity-docgen';
import util from 'util';

dotenv.config();

const exec = util.promisify(require('child_process').exec);

const ETH_KEY = process.env.ETH_KEY;
const accounts = ETH_KEY ? ETH_KEY.split(',') : [];

Expand Down Expand Up @@ -53,6 +56,15 @@ extendEnvironment(hre => {
hre.testingFork = testingFork;
});

// Needed to override and extend in order to make coverage work with typechain
// Without this, it doesn't generate typechains the way we want with custom scripts.
task('coverage').setAction(async (args, hre, runSuper) => {
await exec('yarn typechain:osx');
await exec('yarn typechain:osx-versions');

await runSuper();
});

const ENABLE_DEPLOY_TEST = process.env.TEST_UPDATE_DEPLOY_SCRIPT !== undefined;

console.log('Is deploy test is enabled: ', ENABLE_DEPLOY_TEST);
Expand Down
8 changes: 4 additions & 4 deletions packages/contracts/test/core/dao/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ describe('DAO', function () {

it('reverts if failure is allowed but not enough gas is provided (many actions)', async () => {
const GasConsumer = new GasConsumer__factory(signers[0]);
const gasConsumer = await GasConsumer.deploy();
let gasConsumer = await GasConsumer.deploy();

// Prepare an action array calling `consumeGas` twenty times.
const gasConsumingAction = {
Expand All @@ -856,7 +856,7 @@ describe('DAO', function () {
// Provide too little gas so that the last `to.call` fails, but the remaining gas is enough to finish the subsequent operations.
await expect(
dao.execute(ZERO_BYTES32, [gasConsumingAction], allowFailureMap, {
gasLimit: expectedGas.sub(3200),
gasLimit: expectedGas.sub(3000),
})
).to.be.revertedWithCustomError(dao, 'InsufficientGas');

Expand All @@ -870,12 +870,12 @@ describe('DAO', function () {

it('reverts if failure is allowed but not enough gas is provided (one action)', async () => {
const GasConsumer = new GasConsumer__factory(signers[0]);
const gasConsumer = await GasConsumer.deploy();
let gasConsumer = await GasConsumer.deploy();

// Prepare an action array calling `consumeGas` one times.
const gasConsumingAction = {
to: gasConsumer.address,
data: GasConsumer.interface.encodeFunctionData('consumeGas', [2]),
data: GasConsumer.interface.encodeFunctionData('consumeGas', [1]),
value: 0,
};

Expand Down

0 comments on commit 86899fc

Please sign in to comment.