Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/violet-walls-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nomicfoundation/hardhat-errors": patch
"hardhat": patch
---

Breaking change: removed `timeout` option for Solidity tests in `hardhat.config.ts` file.
1 change: 1 addition & 0 deletions packages/hardhat-errors/src/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ Please double check your transactions' parameters.`,
websiteDescription: `Build info not found for contract while compiling Solidity test contracts.`,
},
RUNNER_TIMEOUT: {
// [DEPRECATED]
number: 801,
messageTemplate: `Runner timed out after {duration} ms.
Comment on lines 1099 to 1102
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the runner timeout option is removed and RUNNER_TIMEOUT appears to be unreachable, consider either removing this descriptor entry (if error codes aren’t part of a stable external API) or updating the actual message/website description to indicate deprecation. A standalone // [DEPRECATED] comment is easy to miss and isn’t consistent with most of the descriptors file.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

@ChristopherDedominici ChristopherDedominici Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on how to deprecate a DESCRIPTOR, do we have a standard process?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't remove them, because this generates the website, and older versions link to it.

I think what you did here makes sense.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const DEFAULT_FUZZ_SEED =
"0x7727ea51af0441c20da14dcd68a15dac8c9ebd589c5be8fa8c87c1d3720450bc";

const solidityTestUserConfigType = z.object({
timeout: z.number().optional(),
fsPermissions: z
.object({
readWriteFile: z.array(z.string()).optional(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { RunOptions } from "./runner.js";
import type { Abi } from "../../../types/artifacts.js";
import type { ChainType } from "../../../types/network.js";
import type { SolidityTestConfig } from "../../../types/test.js";
Expand Down Expand Up @@ -41,12 +40,6 @@ interface SolidityTestConfigParams {
testFunctionOverrides?: TestFunctionOverride[];
}

export function solidityTestConfigToRunOptions(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used only to get the timeout, so now it is no longer needed

config: SolidityTestConfig,
): RunOptions {
return config;
}

export async function solidityTestConfigToSolidityTestRunnerConfigArgs({
chainType,
projectRoot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ import { getGlobalEdrContext } from "../../edr/context.js";

import { formatArtifactId } from "./formatters.js";

export interface RunOptions {
/**
* The maximum time in milliseconds to wait for all the test suites to finish.
*/
timeout?: number;
}

/**
* Run all the given solidity tests and returns the stream of results.
*
Expand All @@ -47,7 +40,6 @@ export function run(
testRunnerConfig: SolidityTestRunnerConfigArgs,
tracingConfig: TracingConfigWithBuffers,
sourceNameToUserSourceName: Map<string, string>,
options?: RunOptions,
): TestsStream {
const stream = new ReadableStream<TestEvent>({
async start(controller) {
Expand All @@ -63,21 +55,6 @@ export function run(
),
);

let timeout: NodeJS.Timeout | undefined;
if (options?.timeout !== undefined) {
timeout = setTimeout(() => {
controller.error(
new HardhatError(
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.RUNNER_TIMEOUT,
{
duration: options.timeout,
suites: Array.from(remainingSuites).join(", "),
},
),
);
}, options.timeout);
}

// TODO: Add support for predeploys once EDR supports them.
try {
const edrContext = await getGlobalEdrContext();
Expand All @@ -96,8 +73,6 @@ export function run(
formatArtifactId(suiteResult.id, sourceNameToUserSourceName),
);
if (remainingSuites.size === 0) {
clearTimeout(timeout);

if (runCompleted) {
controller.close();
}
Expand All @@ -116,8 +91,6 @@ export function run(
} catch (error) {
ensureError(error);

clearTimeout(timeout);

controller.error(
new HardhatError(
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.UNHANDLED_EDR_ERROR_SOLIDITY_TESTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
import {
isTestSuiteArtifact,
warnDeprecatedTestFail,
solidityTestConfigToRunOptions,
solidityTestConfigToSolidityTestRunnerConfigArgs,
} from "./helpers.js";
import { getTestFunctionOverrides } from "./inline-config/index.js";
Expand Down Expand Up @@ -195,8 +194,6 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
})),
ignoreContracts: false,
};
const runOptions = solidityTestConfigToRunOptions(solidityTestConfig);

await hre.hooks.runHandlerChain(
"test",
"onTestRunStart",
Expand All @@ -211,7 +208,6 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
testRunnerConfig,
tracingConfig,
sourceNameToUserSourceName,
runOptions,
);

let failed = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ declare module "../../../types/test.js" {
}

export interface SolidityTestConfigBase {
timeout?: number;
fsPermissions?: {
readWriteFile?: string[];
readFile?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ describe("config validation", () => {
{
test: {
solidity: {
timeout: 5000,
isolate: true,
},
},
},
solidityTestPlugin,
);

assert.equal(hre.config.test.solidity.timeout, 5000);
assert.equal(hre.config.test.solidity.isolate, true);
});

it("should not throw when the `test.solidity` config is not set by the user", async () => {
Expand All @@ -45,7 +45,7 @@ describe("config validation", () => {
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
-- intentionally violating the types for the test */
solidity: {
timeout: "not a number",
isolate: "not a boolean",
} as any,
},
};
Expand All @@ -58,7 +58,7 @@ describe("config validation", () => {
HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG,
{
errors:
"\t* Config error in config.test.solidity.timeout: Expected number, received string",
"\t* Config error in config.test.solidity.isolate: Expected boolean, received string",
},
);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/test/internal/builtin-plugins/test/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("test/config", function () {
it("should keep the existing `test` config provided", async () => {
const existingTestConfig = {
solidity: {
timeout: 123,
isolate: true,
},
};

Expand All @@ -29,8 +29,8 @@ describe("test/config", function () {
});

assert.equal(
hre.config.test.solidity.timeout,
existingTestConfig.solidity.timeout,
hre.config.test.solidity.isolate,
existingTestConfig.solidity.isolate,
);
});
});
Loading