Skip to content

Commit

Permalink
feat: expose the entire runSolidityTests config
Browse files Browse the repository at this point in the history
  • Loading branch information
galargh committed Oct 21, 2024
1 parent 2f8b6d9 commit 2ecb430
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
11 changes: 11 additions & 0 deletions v-next/example-project/contracts/Counter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ contract CounterTest {
require(counter.x() == 0, "Initial value should be 0");
}

function testFailInitialValue() public view {
require(counter.x() == 1, "Initial value should be 1");
}

function testFuzzInc(uint8 x) public {
for (uint8 i = 0; i < x; i++) {
counter.inc();
}
require(counter.x() == x, "Value after calling inc x times should be x");
}

function testFailFuzzInc(uint8 x) public {
for (uint8 i = 0; i < x; i++) {
counter.inc();
}
require(counter.x() == x + 1, "Value after calling inc x times should be x + 1");
}

function invariant() public {
assert(true);
}
Expand Down
3 changes: 3 additions & 0 deletions v-next/example-project/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ const config: HardhatUserConfig = {
version: "0.8.1",
},
},
test: {
testFail: true,
}
},
test: {
version: "0.8.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { RunOptions, TestEvent } from "./types.js";
import type { NewTaskActionFunction } from "../../../types/tasks.js";
import type { SolidityTestRunnerConfigArgs } from "@ignored/edr";

import { finished } from "node:stream/promises";

Expand All @@ -23,18 +24,19 @@ const runSolidityTests: NewTaskActionFunction = async (_taskArguments, hre) => {
)
).filter((artifact) => artifact !== undefined);

const config = {
projectRoot: hre.config.paths.root,
};

let includesFailures = false;
let includesErrors = false;

const profileName = hre.globalOptions.buildProfile;
const profile = hre.config.solidity.profiles[profileName];
const testOptions = profile.test;

const options: RunOptions = { timeout: testOptions.timeout };
const config: SolidityTestRunnerConfigArgs = {
projectRoot: hre.config.paths.root,
...testOptions,
};

const options: RunOptions = testOptions;

const runStream = run(artifacts, testSuiteIds, config, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ declare module "../../../types/config.js" {
settings?: any;
}

export type SolidityTestUserConfig = RunOptions;
export type SolidityTestUserConfig = RunOptions &
Omit<SolidityTestRunnerConfigArgs, "projectRoot">;

export interface SingleVersionSolcUserConfig extends SolcUserConfig {
test?: SolidityTestUserConfig;
Expand Down Expand Up @@ -55,7 +56,8 @@ declare module "../../../types/config.js" {
settings: any;
}

export type SolidityTestConfig = RunOptions;
export type SolidityTestConfig = RunOptions &
Omit<SolidityTestRunnerConfigArgs, "projectRoot">;

export interface SolidityBuildProfileConfig {
compilers: SolcConfig[];
Expand Down Expand Up @@ -85,6 +87,7 @@ declare module "../../../types/config.js" {
import "../../../types/hre.js";
import type { SolidityBuildSystem } from "../../../types/solidity/build-system.js";
import type { RunOptions } from "../solidity-test/types.js";
import type { SolidityTestRunnerConfigArgs } from "@ignored/edr";

declare module "../../../types/hre.js" {
export interface HardhatRuntimeEnvironment {
Expand Down

0 comments on commit 2ecb430

Please sign in to comment.