diff --git a/v-next/example-project/contracts/Counter.t.sol b/v-next/example-project/contracts/Counter.t.sol index b4f50e64ee..a52d195a6d 100644 --- a/v-next/example-project/contracts/Counter.t.sol +++ b/v-next/example-project/contracts/Counter.t.sol @@ -14,6 +14,10 @@ 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(); @@ -21,6 +25,13 @@ contract CounterTest { 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); } diff --git a/v-next/example-project/hardhat.config.ts b/v-next/example-project/hardhat.config.ts index b0ef221349..94f7f77736 100644 --- a/v-next/example-project/hardhat.config.ts +++ b/v-next/example-project/hardhat.config.ts @@ -153,6 +153,9 @@ const config: HardhatUserConfig = { version: "0.8.1", }, }, + test: { + testFail: true, + } }, test: { version: "0.8.2", diff --git a/v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts b/v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts index 017c3ff841..848ac166af 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/solidity-test/task-action.ts @@ -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"; @@ -23,10 +24,6 @@ const runSolidityTests: NewTaskActionFunction = async (_taskArguments, hre) => { ) ).filter((artifact) => artifact !== undefined); - const config = { - projectRoot: hre.config.paths.root, - }; - let includesFailures = false; let includesErrors = false; @@ -34,7 +31,12 @@ const runSolidityTests: NewTaskActionFunction = async (_taskArguments, hre) => { 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); diff --git a/v-next/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts b/v-next/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts index 209501cad5..84b7f07e7f 100644 --- a/v-next/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts +++ b/v-next/hardhat/src/internal/builtin-plugins/solidity/type-extensions.ts @@ -13,7 +13,8 @@ declare module "../../../types/config.js" { settings?: any; } - export type SolidityTestUserConfig = RunOptions; + export type SolidityTestUserConfig = RunOptions & + Omit; export interface SingleVersionSolcUserConfig extends SolcUserConfig { test?: SolidityTestUserConfig; @@ -55,7 +56,8 @@ declare module "../../../types/config.js" { settings: any; } - export type SolidityTestConfig = RunOptions; + export type SolidityTestConfig = RunOptions & + Omit; export interface SolidityBuildProfileConfig { compilers: SolcConfig[]; @@ -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 {