hardhat 3.1.11 → 3.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts +53 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js +288 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.d.ts +0 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js +2 -14
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts +5 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js +14 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js +35 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts +45 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +276 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts +22 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +88 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -0
- package/dist/src/internal/builtin-plugins/index.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts +3 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/config.js +9 -0
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +4 -10
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts +5 -0
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +10 -5
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts +15 -10
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.js +34 -12
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/types/test.d.ts +7 -0
- package/dist/src/types/test.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +473 -0
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +3 -17
- package/src/internal/builtin-plugins/gas-analytics/helpers.ts +29 -0
- package/src/internal/builtin-plugins/gas-analytics/index.ts +36 -2
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +454 -0
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +172 -0
- package/src/internal/builtin-plugins/index.ts +1 -1
- package/src/internal/builtin-plugins/solidity-test/config.ts +15 -0
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +6 -14
- package/src/internal/builtin-plugins/solidity-test/index.ts +0 -1
- package/src/internal/builtin-plugins/solidity-test/runner.ts +2 -2
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +17 -8
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +17 -10
- package/src/internal/builtin-plugins/test/task-action.ts +36 -18
- package/src/types/test.ts +8 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +2 -2
- package/templates/hardhat-3/02-mocha-ethers/package.json +2 -2
- package/templates/hardhat-3/03-minimal/package.json +1 -1
|
@@ -44,7 +44,7 @@ export function run(
|
|
|
44
44
|
chainType: ChainType,
|
|
45
45
|
artifacts: Artifact[],
|
|
46
46
|
testSuiteIds: ArtifactId[],
|
|
47
|
-
|
|
47
|
+
testRunnerConfig: SolidityTestRunnerConfigArgs,
|
|
48
48
|
tracingConfig: TracingConfigWithBuffers,
|
|
49
49
|
sourceNameToUserSourceName: Map<string, string>,
|
|
50
50
|
options?: RunOptions,
|
|
@@ -85,7 +85,7 @@ export function run(
|
|
|
85
85
|
hardhatChainTypeToEdrChainType(chainType),
|
|
86
86
|
artifacts,
|
|
87
87
|
testSuiteIds,
|
|
88
|
-
|
|
88
|
+
testRunnerConfig,
|
|
89
89
|
tracingConfig,
|
|
90
90
|
(suiteResult) => {
|
|
91
91
|
controller.enqueue({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RunOptions } from "./runner.js";
|
|
2
2
|
import type { TestEvent } from "./types.js";
|
|
3
3
|
import type { NewTaskActionFunction } from "../../../types/tasks.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { TestRunResult } from "../../../types/test.js";
|
|
5
5
|
import type { Result } from "../../../types/utils.js";
|
|
6
6
|
import type {
|
|
7
7
|
Artifact as EdrArtifact,
|
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
ObservabilityConfig,
|
|
10
10
|
SolidityTestRunnerConfigArgs,
|
|
11
11
|
TracingConfigWithBuffers,
|
|
12
|
+
SuiteResult,
|
|
12
13
|
} from "@nomicfoundation/edr";
|
|
13
14
|
|
|
14
15
|
import { finished } from "node:stream/promises";
|
|
@@ -46,10 +47,14 @@ interface TestActionArguments {
|
|
|
46
47
|
testSummaryIndex: number;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
export interface SolidityTestRunResult extends TestRunResult {
|
|
51
|
+
suiteResults: SuiteResult[];
|
|
52
|
+
}
|
|
53
|
+
|
|
49
54
|
const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
50
55
|
{ testFiles, chainType, grep, noCompile, verbosity, testSummaryIndex },
|
|
51
56
|
hre,
|
|
52
|
-
): Promise<Result<
|
|
57
|
+
): Promise<Result<SolidityTestRunResult, SolidityTestRunResult>> => {
|
|
53
58
|
assertHardhatInvariant(
|
|
54
59
|
hre instanceof HardhatRuntimeEnvironmentImplementation,
|
|
55
60
|
"Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
|
|
@@ -161,7 +166,7 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
168
|
|
|
164
|
-
const
|
|
169
|
+
const testRunnerConfig: SolidityTestRunnerConfigArgs =
|
|
165
170
|
await solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
166
171
|
chainType,
|
|
167
172
|
projectRoot: hre.config.paths.root,
|
|
@@ -190,7 +195,7 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
190
195
|
chainType,
|
|
191
196
|
edrArtifacts.map(({ edrArtifact }) => edrArtifact),
|
|
192
197
|
testSuiteIds,
|
|
193
|
-
|
|
198
|
+
testRunnerConfig,
|
|
194
199
|
tracingConfig,
|
|
195
200
|
sourceNameToUserSourceName,
|
|
196
201
|
options,
|
|
@@ -200,10 +205,11 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
200
205
|
let passed = 0;
|
|
201
206
|
let skipped = 0;
|
|
202
207
|
let failureOutput = "";
|
|
203
|
-
|
|
208
|
+
const suiteResults: SuiteResult[] = [];
|
|
204
209
|
const testReporterStream = runStream
|
|
205
210
|
.on("data", (event: TestEvent) => {
|
|
206
211
|
if (event.type === "suite:done") {
|
|
212
|
+
suiteResults.push(event.data);
|
|
207
213
|
if (event.data.testResults.some(({ status }) => status === "Failure")) {
|
|
208
214
|
includesFailures = true;
|
|
209
215
|
}
|
|
@@ -284,11 +290,14 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
284
290
|
|
|
285
291
|
console.log();
|
|
286
292
|
|
|
287
|
-
const
|
|
293
|
+
const result = {
|
|
294
|
+
summary: { failed, passed, skipped, todo: 0, failureOutput },
|
|
295
|
+
suiteResults,
|
|
296
|
+
};
|
|
288
297
|
|
|
289
298
|
return includesFailures || includesErrors
|
|
290
|
-
? errorResult(
|
|
291
|
-
: successfulResult(
|
|
299
|
+
? errorResult(result)
|
|
300
|
+
: successfulResult(result);
|
|
292
301
|
};
|
|
293
302
|
|
|
294
303
|
export default runSolidityTests;
|
|
@@ -15,6 +15,21 @@ declare module "../../../types/config.js" {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
declare module "../../../types/test.js" {
|
|
18
|
+
export interface SolidityTestFuzzConfigBase {
|
|
19
|
+
failurePersistDir?: string;
|
|
20
|
+
failurePersistFile?: string;
|
|
21
|
+
runs?: number;
|
|
22
|
+
maxTestRejects?: number;
|
|
23
|
+
seed?: string;
|
|
24
|
+
dictionaryWeight?: number;
|
|
25
|
+
includeStorage?: boolean;
|
|
26
|
+
includePushBytes?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface SolidityTestFuzzConfig extends SolidityTestFuzzConfigBase {
|
|
30
|
+
seed: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
export interface SolidityTestConfigBase {
|
|
19
34
|
timeout?: number;
|
|
20
35
|
fsPermissions?: {
|
|
@@ -38,16 +53,7 @@ declare module "../../../types/test.js" {
|
|
|
38
53
|
gasLimit?: bigint;
|
|
39
54
|
blockGasLimit?: bigint | false;
|
|
40
55
|
|
|
41
|
-
fuzz?:
|
|
42
|
-
failurePersistDir?: string;
|
|
43
|
-
failurePersistFile?: string;
|
|
44
|
-
runs?: number;
|
|
45
|
-
maxTestRejects?: number;
|
|
46
|
-
seed?: string;
|
|
47
|
-
dictionaryWeight?: number;
|
|
48
|
-
includeStorage?: boolean;
|
|
49
|
-
includePushBytes?: boolean;
|
|
50
|
-
};
|
|
56
|
+
fuzz?: SolidityTestFuzzConfigBase;
|
|
51
57
|
invariant?: {
|
|
52
58
|
failurePersistDir?: string;
|
|
53
59
|
runs?: number;
|
|
@@ -82,6 +88,7 @@ declare module "../../../types/test.js" {
|
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
export interface SolidityTestConfig extends SolidityTestConfigBase {
|
|
91
|
+
fuzz: SolidityTestFuzzConfig;
|
|
85
92
|
forking?: SolidityTestForkingConfig;
|
|
86
93
|
}
|
|
87
94
|
export interface HardhatTestConfig {
|
|
@@ -46,8 +46,14 @@ function isTestSummary(value: unknown): value is PartialTestSummary {
|
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
function isTestRunResult(
|
|
50
|
+
value: unknown,
|
|
51
|
+
): value is { summary: PartialTestSummary } {
|
|
52
|
+
return isObject(value) && "summary" in value && isTestSummary(value.summary);
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
50
|
-
{ testFiles, chainType, grep, noCompile, verbosity },
|
|
56
|
+
{ testFiles, chainType, grep, noCompile, verbosity, ...otherArgs },
|
|
51
57
|
hre,
|
|
52
58
|
): Promise<Result<void, void>> => {
|
|
53
59
|
// If this code is executed, it means the user has not specified a test runner.
|
|
@@ -101,24 +107,41 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
101
107
|
args.verbosity = verbosity;
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
for (const [key, value] of Object.entries(otherArgs)) {
|
|
111
|
+
if (subtask.options.has(key)) {
|
|
112
|
+
args[key] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
104
116
|
if (subtask.options.has("testSummaryIndex")) {
|
|
105
117
|
args.testSummaryIndex = failureIndex;
|
|
106
118
|
}
|
|
107
119
|
|
|
108
120
|
const subtaskResult = await subtask.run(args);
|
|
109
121
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const summary = isSubtaskResult
|
|
116
|
-
? subtaskResult.success
|
|
122
|
+
let summary: PartialTestSummary | undefined;
|
|
123
|
+
let subtaskFailed = false;
|
|
124
|
+
|
|
125
|
+
if (isResult(subtaskResult, isTestRunResult, isTestRunResult)) {
|
|
126
|
+
const testRunResult = subtaskResult.success
|
|
117
127
|
? subtaskResult.value
|
|
118
|
-
: subtaskResult.error
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
: subtaskResult.error;
|
|
129
|
+
summary = testRunResult.summary;
|
|
130
|
+
subtaskFailed = !subtaskResult.success;
|
|
131
|
+
} else if (isResult(subtaskResult, isTestSummary, isTestSummary)) {
|
|
132
|
+
// Support plugins that return Result<TestSummary, TestSummary>
|
|
133
|
+
summary = subtaskResult.success
|
|
134
|
+
? subtaskResult.value
|
|
135
|
+
: subtaskResult.error;
|
|
136
|
+
subtaskFailed = !subtaskResult.success;
|
|
137
|
+
} else if (isTestSummary(subtaskResult)) {
|
|
138
|
+
// Support plugins that return TestSummary directly
|
|
139
|
+
summary = subtaskResult;
|
|
140
|
+
subtaskFailed = process.exitCode !== undefined && process.exitCode !== 0;
|
|
141
|
+
} else {
|
|
142
|
+
// Fallback for plugins that don't return a summary at all
|
|
143
|
+
subtaskFailed = process.exitCode !== undefined && process.exitCode !== 0;
|
|
144
|
+
}
|
|
122
145
|
|
|
123
146
|
if (summary !== undefined) {
|
|
124
147
|
const summaryId = subtask.id[subtask.id.length - 1];
|
|
@@ -133,12 +156,7 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
133
156
|
}
|
|
134
157
|
}
|
|
135
158
|
|
|
136
|
-
if (
|
|
137
|
-
(isSubtaskResult && !subtaskResult.success) ||
|
|
138
|
-
// Backwards compatibility: old plugins may not return a Result, so fall
|
|
139
|
-
// back to the process exit code to detect failures
|
|
140
|
-
(process.exitCode !== undefined && process.exitCode !== 0)
|
|
141
|
-
) {
|
|
159
|
+
if (subtaskFailed) {
|
|
142
160
|
hasFailures = true;
|
|
143
161
|
}
|
|
144
162
|
}
|
package/src/types/test.ts
CHANGED
|
@@ -17,3 +17,11 @@ export interface TestSummary {
|
|
|
17
17
|
todo: number;
|
|
18
18
|
failureOutput?: string;
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result of a test run, wrapping a TestSummary. Plugins can extend this
|
|
23
|
+
* interface to include additional data (e.g., suite results).
|
|
24
|
+
*/
|
|
25
|
+
export interface TestRunResult {
|
|
26
|
+
summary: TestSummary;
|
|
27
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "A TypeScript Hardhat project using Node Test Runner and Viem",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"hardhat": "workspace:^3.1.
|
|
8
|
+
"hardhat": "workspace:^3.1.12",
|
|
9
9
|
"@nomicfoundation/hardhat-toolbox-viem": "workspace:^5.0.3",
|
|
10
10
|
"@nomicfoundation/hardhat-ignition": "workspace:^3.0.9",
|
|
11
11
|
"@types/node": "^22.8.5",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@nomicfoundation/hardhat-ignition-viem": "workspace:^3.0.9",
|
|
18
18
|
"@nomicfoundation/hardhat-keystore": "workspace:^3.0.5",
|
|
19
19
|
"@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.4",
|
|
20
|
-
"@nomicfoundation/hardhat-node-test-runner": "workspace:^3.0.
|
|
20
|
+
"@nomicfoundation/hardhat-node-test-runner": "workspace:^3.0.11",
|
|
21
21
|
"@nomicfoundation/hardhat-viem": "workspace:^3.0.4",
|
|
22
22
|
"@nomicfoundation/hardhat-viem-assertions": "workspace:^3.0.7",
|
|
23
23
|
"@nomicfoundation/hardhat-verify": "workspace:^3.0.12",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "A TypeScript Hardhat project using Mocha and Ethers.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"hardhat": "workspace:^3.1.
|
|
8
|
+
"hardhat": "workspace:^3.1.12",
|
|
9
9
|
"@nomicfoundation/hardhat-toolbox-mocha-ethers": "workspace:^3.0.3",
|
|
10
10
|
"@nomicfoundation/hardhat-ethers": "workspace:^4.0.6",
|
|
11
11
|
"@nomicfoundation/hardhat-ignition": "workspace:^3.0.9",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@nomicfoundation/hardhat-ignition": "workspace:^3.0.9",
|
|
26
26
|
"@nomicfoundation/hardhat-ignition-ethers": "workspace:^3.0.9",
|
|
27
27
|
"@nomicfoundation/hardhat-keystore": "workspace:^3.0.5",
|
|
28
|
-
"@nomicfoundation/hardhat-mocha": "workspace:^3.0.
|
|
28
|
+
"@nomicfoundation/hardhat-mocha": "workspace:^3.0.13",
|
|
29
29
|
"@nomicfoundation/hardhat-network-helpers": "workspace:^3.0.4",
|
|
30
30
|
"@nomicfoundation/hardhat-typechain": "workspace:^3.0.4",
|
|
31
31
|
"@nomicfoundation/hardhat-verify": "workspace:^3.0.12",
|