hardhat 3.14.0 → 3.15.0
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 +12 -0
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts +6 -1
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.js +41 -0
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +16 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +45 -2
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +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 +18 -1
- 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.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +15 -16
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/package.json +2 -2
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +2 -2
- package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +1 -1
- package/src/internal/builtin-plugins/solidity-test/formatters.ts +60 -1
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +56 -4
- package/src/internal/builtin-plugins/solidity-test/runner.ts +33 -1
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +20 -20
- package/templates/01-node-test-runner-viem/contracts/Counter.sol +1 -1
- package/templates/01-node-test-runner-viem/contracts/Counter.t.sol +1 -1
- package/templates/01-node-test-runner-viem/hardhat.config.ts +2 -2
- package/templates/01-node-test-runner-viem/package.json +2 -2
- package/templates/02-mocha-ethers/contracts/Counter.sol +1 -1
- package/templates/02-mocha-ethers/contracts/Counter.t.sol +1 -1
- package/templates/02-mocha-ethers/hardhat.config.ts +2 -2
- package/templates/02-mocha-ethers/package.json +2 -2
- package/templates/03-minimal/hardhat.config.ts +1 -1
- package/templates/03-minimal/package.json +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts +0 -9
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js +0 -24
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts +0 -24
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js +0 -80
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts +0 -13
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js +0 -146
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts +0 -19
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js +0 -134
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts +0 -10
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js +0 -2
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts +0 -13
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js +0 -96
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js.map +0 -1
- package/src/internal/builtin-plugins/solidity-test/inline-config/constants.ts +0 -25
- package/src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts +0 -110
- package/src/internal/builtin-plugins/solidity-test/inline-config/index.ts +0 -285
- package/src/internal/builtin-plugins/solidity-test/inline-config/parsing.ts +0 -187
- package/src/internal/builtin-plugins/solidity-test/inline-config/types.ts +0 -9
- package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +0 -144
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TestsStream } from "./types.js";
|
|
1
2
|
import type { Abi } from "../../../types/artifacts.js";
|
|
2
3
|
import type { ChainType } from "../../../types/network.js";
|
|
3
4
|
import type { SolidityTestProfileConfig } from "../../../types/test.js";
|
|
@@ -6,9 +7,10 @@ import type {
|
|
|
6
7
|
PathPermission,
|
|
7
8
|
Artifact,
|
|
8
9
|
ObservabilityConfig,
|
|
9
|
-
TestFunctionOverride,
|
|
10
10
|
} from "@nomicfoundation/edr";
|
|
11
|
+
import type { Writable } from "node:stream";
|
|
11
12
|
|
|
13
|
+
import { finished } from "node:stream/promises";
|
|
12
14
|
import { styleText } from "node:util";
|
|
13
15
|
|
|
14
16
|
import {
|
|
@@ -43,8 +45,8 @@ interface SolidityTestConfigParams {
|
|
|
43
45
|
testPattern?: string;
|
|
44
46
|
excludeTestPattern?: string;
|
|
45
47
|
generateGasReport: boolean;
|
|
46
|
-
testFunctionOverrides?: TestFunctionOverride[];
|
|
47
48
|
eip712CanonicalTypes?: string[];
|
|
49
|
+
testSourcePaths?: Record<string, string>;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export async function solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
@@ -57,8 +59,8 @@ export async function solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
|
57
59
|
testPattern,
|
|
58
60
|
excludeTestPattern,
|
|
59
61
|
generateGasReport,
|
|
60
|
-
testFunctionOverrides,
|
|
61
62
|
eip712CanonicalTypes,
|
|
63
|
+
testSourcePaths,
|
|
62
64
|
}: SolidityTestConfigParams): Promise<SolidityTestRunnerConfigArgs> {
|
|
63
65
|
const fsPermissions: PathPermission[] | undefined = [
|
|
64
66
|
config.fsPermissions?.readWriteFile?.map((p) => ({
|
|
@@ -171,8 +173,8 @@ export async function solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
|
171
173
|
collectStackTraces: shouldAlwaysCollectStackTraces
|
|
172
174
|
? CollectStackTraces.Always
|
|
173
175
|
: CollectStackTraces.OnFailure,
|
|
174
|
-
testFunctionOverrides,
|
|
175
176
|
eip712CanonicalTypes,
|
|
177
|
+
testSourcePaths,
|
|
176
178
|
};
|
|
177
179
|
}
|
|
178
180
|
|
|
@@ -194,6 +196,56 @@ export function isTestSuiteArtifact(artifact: Artifact): boolean {
|
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Writes the test reporter's output to `output` and waits for the test run to
|
|
201
|
+
* complete, returning the error that failed it, if any.
|
|
202
|
+
*
|
|
203
|
+
* @param runStream The runner's stream of test events.
|
|
204
|
+
* @param reporterStream The reporter's stream of output, composed from
|
|
205
|
+
* `runStream`.
|
|
206
|
+
* @param output Where the reporter's output is written to.
|
|
207
|
+
* @returns The error that failed the run, or `undefined` if it succeeded.
|
|
208
|
+
*/
|
|
209
|
+
export async function writeTestRunOutput(
|
|
210
|
+
runStream: TestsStream,
|
|
211
|
+
reporterStream: NodeJS.ReadableStream,
|
|
212
|
+
output: Writable,
|
|
213
|
+
): Promise<unknown> {
|
|
214
|
+
const outputStream = reporterStream.pipe(output);
|
|
215
|
+
|
|
216
|
+
// When the runner reports an error it destroys the run stream with it, which
|
|
217
|
+
// also destroys the reporter stream composed from it. `pipe()` neither
|
|
218
|
+
// forwards that error to the output stream nor ends it, so without this
|
|
219
|
+
// listener the reporter stream emits an `error` event with nothing listening,
|
|
220
|
+
// crashing the process, and `finished(outputStream)` below never settles.
|
|
221
|
+
// Attached before any `await` so that it can't miss the event.
|
|
222
|
+
let reporterStreamError: Error | undefined;
|
|
223
|
+
reporterStream.on("error", (error: Error) => {
|
|
224
|
+
reporterStreamError = error;
|
|
225
|
+
if (!outputStream.writableEnded) {
|
|
226
|
+
outputStream.end();
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
let runError: unknown;
|
|
231
|
+
try {
|
|
232
|
+
// NOTE: We're awaiting the original run stream to finish to catch any
|
|
233
|
+
// errors produced by the runner.
|
|
234
|
+
await finished(runStream);
|
|
235
|
+
|
|
236
|
+
// We also await the output stream to finish, as we want to wait for it
|
|
237
|
+
// to avoid returning before the whole output was generated.
|
|
238
|
+
await finished(outputStream);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
runError = error;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Neither await above surfaces an error that reached the reporter stream
|
|
244
|
+
// without failing the run stream, e.g. one thrown by the reporter after the
|
|
245
|
+
// run stream already ended.
|
|
246
|
+
return runError ?? reporterStreamError;
|
|
247
|
+
}
|
|
248
|
+
|
|
197
249
|
export function warnDeprecatedTestFail(
|
|
198
250
|
artifact: Artifact,
|
|
199
251
|
sourceNameToUserSourceName: Map<string, string>,
|
|
@@ -3,6 +3,7 @@ import type { ChainType } from "../../../types/network.js";
|
|
|
3
3
|
import type {
|
|
4
4
|
ArtifactId,
|
|
5
5
|
Artifact,
|
|
6
|
+
InlineConfigError,
|
|
6
7
|
SolidityTestRunnerConfigArgs,
|
|
7
8
|
TracingConfigWithBuffers,
|
|
8
9
|
} from "@nomicfoundation/edr";
|
|
@@ -15,7 +16,7 @@ import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
|
15
16
|
import { hardhatChainTypeToEdrChainType } from "../../edr/chain-type.js";
|
|
16
17
|
import { getGlobalEdrContext } from "../../edr/context.js";
|
|
17
18
|
|
|
18
|
-
import { formatArtifactId } from "./formatters.js";
|
|
19
|
+
import { formatArtifactId, formatInlineConfigErrors } from "./formatters.js";
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Run all the given solidity tests and returns the stream of results.
|
|
@@ -100,6 +101,24 @@ export function run(
|
|
|
100
101
|
} catch (error) {
|
|
101
102
|
ensureError(error);
|
|
102
103
|
|
|
104
|
+
// EDR reports the problems it found in the user's inline test config as
|
|
105
|
+
// an `inlineConfigErrors` property on the error. Report them as a
|
|
106
|
+
// dedicated Hardhat error instead of an unhandled EDR error.
|
|
107
|
+
if (hasInlineConfigErrors(error)) {
|
|
108
|
+
stream.destroy(
|
|
109
|
+
new HardhatError(
|
|
110
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INVALID_INLINE_CONFIG,
|
|
111
|
+
{
|
|
112
|
+
errors: formatInlineConfigErrors(
|
|
113
|
+
error.inlineConfigErrors,
|
|
114
|
+
sourceNameToUserSourceName,
|
|
115
|
+
),
|
|
116
|
+
},
|
|
117
|
+
),
|
|
118
|
+
);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
103
122
|
stream.destroy(
|
|
104
123
|
new HardhatError(
|
|
105
124
|
HardhatError.ERRORS.CORE.SOLIDITY_TESTS
|
|
@@ -114,3 +133,16 @@ export function run(
|
|
|
114
133
|
|
|
115
134
|
return stream;
|
|
116
135
|
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* EDR attaches the structured inline-config problems to the error that rejects
|
|
139
|
+
* `runSolidityTests`, but as a property of an `Error` rather than a typed
|
|
140
|
+
* error class, so we have to assert their type here.
|
|
141
|
+
*/
|
|
142
|
+
function hasInlineConfigErrors(
|
|
143
|
+
error: Error,
|
|
144
|
+
): error is Error & { inlineConfigErrors: InlineConfigError[] } {
|
|
145
|
+
return (
|
|
146
|
+
"inlineConfigErrors" in error && Array.isArray(error.inlineConfigErrors)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
@@ -16,8 +16,6 @@ import type {
|
|
|
16
16
|
SuiteResult,
|
|
17
17
|
} from "@nomicfoundation/edr";
|
|
18
18
|
|
|
19
|
-
import { finished } from "node:stream/promises";
|
|
20
|
-
|
|
21
19
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
22
20
|
import { exists } from "@nomicfoundation/hardhat-utils/fs";
|
|
23
21
|
import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
|
|
@@ -40,8 +38,8 @@ import {
|
|
|
40
38
|
isTestSuiteArtifact,
|
|
41
39
|
warnDeprecatedTestFail,
|
|
42
40
|
solidityTestConfigToSolidityTestRunnerConfigArgs,
|
|
41
|
+
writeTestRunOutput,
|
|
43
42
|
} from "./helpers.js";
|
|
44
|
-
import { getTestFunctionOverrides } from "./inline-config/index.js";
|
|
45
43
|
import { testReporter } from "./reporter.js";
|
|
46
44
|
import { run } from "./runner.js";
|
|
47
45
|
import { DEFAULT_TEST_PROFILE } from "./test-profiles.js";
|
|
@@ -198,6 +196,19 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
198
196
|
({ edrArtifact }) => edrArtifact.id,
|
|
199
197
|
);
|
|
200
198
|
|
|
199
|
+
// Maps each test suite's solc source name to its absolute path on disk, so
|
|
200
|
+
// EDR can read the inline test configuration from the sources. A source
|
|
201
|
+
// without an entry has no inline configuration collected.
|
|
202
|
+
//
|
|
203
|
+
// EDR skips every source that carries no inline config directive, so there's
|
|
204
|
+
// no need to filter these paths here.
|
|
205
|
+
const testSourcePaths = Object.fromEntries(
|
|
206
|
+
testSuiteArtifacts.map(({ userSourceName, edrArtifact }) => [
|
|
207
|
+
edrArtifact.id.source,
|
|
208
|
+
resolveFromRoot(hre.config.paths.root, userSourceName),
|
|
209
|
+
]),
|
|
210
|
+
);
|
|
211
|
+
|
|
201
212
|
console.log("Running Solidity tests");
|
|
202
213
|
console.log();
|
|
203
214
|
|
|
@@ -233,11 +244,6 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
233
244
|
}
|
|
234
245
|
}
|
|
235
246
|
|
|
236
|
-
const testFunctionOverrides = await getTestFunctionOverrides(
|
|
237
|
-
testSuiteArtifacts,
|
|
238
|
-
allBuildInfosAndOutputs,
|
|
239
|
-
);
|
|
240
|
-
|
|
241
247
|
const eip712CanonicalTypes = await collectEip712CanonicalTypes(
|
|
242
248
|
allBuildInfosAndOutputs,
|
|
243
249
|
sourceNameToUserSourceName,
|
|
@@ -257,8 +263,8 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
257
263
|
generateGasReport:
|
|
258
264
|
hre.globalOptions.gasStats ||
|
|
259
265
|
hre.globalOptions.gasStatsJson !== undefined,
|
|
260
|
-
testFunctionOverrides,
|
|
261
266
|
eip712CanonicalTypes,
|
|
267
|
+
testSourcePaths,
|
|
262
268
|
});
|
|
263
269
|
const tracingConfig: TracingConfigWithBuffers = {
|
|
264
270
|
buildInfos: allBuildInfosAndOutputs.map(({ buildInfo, output }) => ({
|
|
@@ -340,20 +346,14 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
340
346
|
}
|
|
341
347
|
});
|
|
342
348
|
|
|
343
|
-
const
|
|
349
|
+
const testRunError = await writeTestRunOutput(
|
|
350
|
+
runStream,
|
|
351
|
+
testReporterStream,
|
|
344
352
|
createNonClosingWriter(process.stdout),
|
|
345
353
|
);
|
|
346
354
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
// errors produced by the runner.
|
|
350
|
-
await finished(runStream);
|
|
351
|
-
|
|
352
|
-
// We also await the output stream to finish, as we want to wait for it
|
|
353
|
-
// to avoid returning before the whole output was generated.
|
|
354
|
-
await finished(outputStream);
|
|
355
|
-
} catch (error) {
|
|
356
|
-
console.error(error);
|
|
355
|
+
if (testRunError !== undefined) {
|
|
356
|
+
console.error(testRunError);
|
|
357
357
|
includesErrors = true;
|
|
358
358
|
}
|
|
359
359
|
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"description": "A TypeScript Hardhat project using Node Test Runner and Viem",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"hardhat": "workspace:^3.
|
|
8
|
+
"hardhat": "workspace:^3.15.0",
|
|
9
9
|
"@nomicfoundation/hardhat-toolbox-viem": "workspace:^5.0.7",
|
|
10
10
|
"@nomicfoundation/hardhat-ignition": "workspace:^3.1.8",
|
|
11
11
|
"@types/node": "^22.8.5",
|
|
12
|
-
"forge-std": "foundry-rs/forge-std#v1.
|
|
12
|
+
"forge-std": "foundry-rs/forge-std#v1.16.2",
|
|
13
13
|
"typescript": "~6.0.3",
|
|
14
14
|
"viem": "^2.47.6"
|
|
15
15
|
},
|
|
@@ -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.
|
|
8
|
+
"hardhat": "workspace:^3.15.0",
|
|
9
9
|
"@nomicfoundation/hardhat-toolbox-mocha-ethers": "workspace:^3.0.7",
|
|
10
10
|
"@nomicfoundation/hardhat-ethers": "workspace:^4.0.15",
|
|
11
11
|
"@nomicfoundation/hardhat-ignition": "workspace:^3.1.8",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@types/node": "^22.8.5",
|
|
16
16
|
"chai": "^6.2.2",
|
|
17
17
|
"ethers": "^6.14.0",
|
|
18
|
-
"forge-std": "foundry-rs/forge-std#v1.
|
|
18
|
+
"forge-std": "foundry-rs/forge-std#v1.16.2",
|
|
19
19
|
"mocha": "^11.0.0",
|
|
20
20
|
"typescript": "~6.0.3"
|
|
21
21
|
},
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const HARDHAT_CONFIG_PREFIX = "hardhat-config:";
|
|
2
|
-
export declare const FORGE_CONFIG_PREFIX = "forge-config:";
|
|
3
|
-
/**
|
|
4
|
-
* All supported inline config keys and their expected value types.
|
|
5
|
-
*/
|
|
6
|
-
export declare const KEY_TYPES: Record<string, "number" | "boolean" | "string">;
|
|
7
|
-
/** Top-level key categories (e.g. "fuzz", "invariant", "allowInternalExpectRevert"). */
|
|
8
|
-
export declare const TOP_LEVEL_KEYS: string[];
|
|
9
|
-
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/inline-config/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AACvD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAarE,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,cAAc,EAAE,MAAM,EAElC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export const HARDHAT_CONFIG_PREFIX = "hardhat-config:";
|
|
2
|
-
export const FORGE_CONFIG_PREFIX = "forge-config:";
|
|
3
|
-
/**
|
|
4
|
-
* All supported inline config keys and their expected value types.
|
|
5
|
-
*/
|
|
6
|
-
export const KEY_TYPES = {
|
|
7
|
-
"fuzz.runs": "number",
|
|
8
|
-
"fuzz.maxTestRejects": "number",
|
|
9
|
-
"fuzz.showLogs": "boolean",
|
|
10
|
-
"fuzz.timeout": "number",
|
|
11
|
-
"invariant.runs": "number",
|
|
12
|
-
"invariant.depth": "number",
|
|
13
|
-
"invariant.failOnRevert": "boolean",
|
|
14
|
-
"invariant.callOverride": "boolean",
|
|
15
|
-
"invariant.timeout": "number",
|
|
16
|
-
allowInternalExpectRevert: "boolean",
|
|
17
|
-
isolate: "boolean",
|
|
18
|
-
evmVersion: "string",
|
|
19
|
-
};
|
|
20
|
-
/** Top-level key categories (e.g. "fuzz", "invariant", "allowInternalExpectRevert"). */
|
|
21
|
-
export const TOP_LEVEL_KEYS = [
|
|
22
|
-
...new Set(Object.keys(KEY_TYPES).map((k) => k.split(".")[0])),
|
|
23
|
-
];
|
|
24
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/inline-config/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AACvD,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoD;IACxE,WAAW,EAAE,QAAQ;IACrB,qBAAqB,EAAE,QAAQ;IAC/B,eAAe,EAAE,SAAS;IAC1B,cAAc,EAAE,QAAQ;IACxB,gBAAgB,EAAE,QAAQ;IAC1B,iBAAiB,EAAE,QAAQ;IAC3B,wBAAwB,EAAE,SAAS;IACnC,wBAAwB,EAAE,SAAS;IACnC,mBAAmB,EAAE,QAAQ;IAC7B,yBAAyB,EAAE,SAAS;IACpC,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,QAAQ;CACrB,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAa;IACtC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/D,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { RawInlineOverride } from "./types.js";
|
|
2
|
-
import type { TestFunctionConfigOverride } from "@nomicfoundation/edr";
|
|
3
|
-
/**
|
|
4
|
-
* Returns true if the build info bytes contain either of the inline config
|
|
5
|
-
* prefixes.
|
|
6
|
-
*/
|
|
7
|
-
export declare function buildInfoContainsInlineConfig(buildInfoBytes: Uint8Array): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Finds the function selector for a given function name in the methodIdentifiers
|
|
10
|
-
* map. Matches the first entry whose signature starts with `functionName(`.
|
|
11
|
-
* Returns the selector prefixed with "0x".
|
|
12
|
-
*/
|
|
13
|
-
export declare function resolveFunctionSelector(methodIdentifiers: Record<string, string>, functionName: string): string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Converts a validated set of raw overrides into a TestFunctionConfigOverride
|
|
16
|
-
* object.
|
|
17
|
-
*/
|
|
18
|
-
export declare function buildConfigOverride(overrides: RawInlineOverride[]): TestFunctionConfigOverride;
|
|
19
|
-
/**
|
|
20
|
-
* Constructs a fully qualified function name, in the format
|
|
21
|
-
* "source.sol:ContractName#functionName".
|
|
22
|
-
*/
|
|
23
|
-
export declare function getFunctionFqn(inputSourceName: string, contractName: string, functionName: string): string;
|
|
24
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAavE;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,cAAc,EAAE,UAAU,GACzB,OAAO,CAKT;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAUpB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,iBAAiB,EAAE,GAC7B,0BAA0B,CA4C5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,GACnB,MAAM,CAER"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
|
|
2
|
-
import { bytesIncludesUtf8String } from "@nomicfoundation/hardhat-utils/bytes";
|
|
3
|
-
import { getFullyQualifiedName } from "../../../../utils/contract-names.js";
|
|
4
|
-
import { HARDHAT_CONFIG_PREFIX, FORGE_CONFIG_PREFIX, KEY_TYPES, } from "./constants.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns true if the build info bytes contain either of the inline config
|
|
7
|
-
* prefixes.
|
|
8
|
-
*/
|
|
9
|
-
export function buildInfoContainsInlineConfig(buildInfoBytes) {
|
|
10
|
-
return (bytesIncludesUtf8String(buildInfoBytes, HARDHAT_CONFIG_PREFIX) ||
|
|
11
|
-
bytesIncludesUtf8String(buildInfoBytes, FORGE_CONFIG_PREFIX));
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Finds the function selector for a given function name in the methodIdentifiers
|
|
15
|
-
* map. Matches the first entry whose signature starts with `functionName(`.
|
|
16
|
-
* Returns the selector prefixed with "0x".
|
|
17
|
-
*/
|
|
18
|
-
export function resolveFunctionSelector(methodIdentifiers, functionName) {
|
|
19
|
-
const prefix = `${functionName}(`;
|
|
20
|
-
for (const [signature, selector] of Object.entries(methodIdentifiers)) {
|
|
21
|
-
if (signature.startsWith(prefix)) {
|
|
22
|
-
return `0x${selector}`;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Converts a validated set of raw overrides into a TestFunctionConfigOverride
|
|
29
|
-
* object.
|
|
30
|
-
*/
|
|
31
|
-
export function buildConfigOverride(overrides) {
|
|
32
|
-
const config = {};
|
|
33
|
-
const fuzz = {};
|
|
34
|
-
const invariant = {};
|
|
35
|
-
for (const override of overrides) {
|
|
36
|
-
const expectedType = KEY_TYPES[override.key];
|
|
37
|
-
let parsed;
|
|
38
|
-
if (expectedType === "number") {
|
|
39
|
-
parsed = Number(override.rawValue);
|
|
40
|
-
}
|
|
41
|
-
else if (expectedType === "boolean") {
|
|
42
|
-
parsed = override.rawValue.toLowerCase() === "true";
|
|
43
|
-
}
|
|
44
|
-
else if (expectedType === "string") {
|
|
45
|
-
// Validation has already proven the surrounding double quotes.
|
|
46
|
-
parsed = override.rawValue.slice(1, -1);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
assertHardhatInvariant(false, `Unhandled inline config value type for key ${override.key}`);
|
|
50
|
-
}
|
|
51
|
-
const dotIndex = override.key.indexOf(".");
|
|
52
|
-
if (dotIndex === -1) {
|
|
53
|
-
// Top-level key, like "allowInternalExpectRevert"
|
|
54
|
-
config[override.key] = parsed;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
const section = override.key.slice(0, dotIndex);
|
|
58
|
-
const field = override.key.slice(dotIndex + 1);
|
|
59
|
-
const target = section === "fuzz" ? fuzz : invariant;
|
|
60
|
-
target[field] = field === "timeout" ? { time: parsed } : parsed;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (Object.keys(fuzz).length > 0) {
|
|
64
|
-
config.fuzz = fuzz;
|
|
65
|
-
}
|
|
66
|
-
if (Object.keys(invariant).length > 0) {
|
|
67
|
-
config.invariant = invariant;
|
|
68
|
-
}
|
|
69
|
-
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions --
|
|
70
|
-
Cast is safe because we have validated all keys and value types in the previous step. */
|
|
71
|
-
return config;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Constructs a fully qualified function name, in the format
|
|
75
|
-
* "source.sol:ContractName#functionName".
|
|
76
|
-
*/
|
|
77
|
-
export function getFunctionFqn(inputSourceName, contractName, functionName) {
|
|
78
|
-
return `${getFullyQualifiedName(inputSourceName, contractName)}#${functionName}`;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BuildInfoAndOutput, EdrArtifactWithMetadata } from "../edr-artifacts.js";
|
|
2
|
-
import type { TestFunctionOverride } from "@nomicfoundation/edr";
|
|
3
|
-
export type { RawInlineOverride } from "./types.js";
|
|
4
|
-
export { buildInfoContainsInlineConfig, resolveFunctionSelector, buildConfigOverride, getFunctionFqn, } from "./helpers.js";
|
|
5
|
-
export { extractInlineConfigFromAst, extractDocText, parseInlineConfigLine, } from "./parsing.js";
|
|
6
|
-
export { validateInlineOverrides } from "./validation.js";
|
|
7
|
-
/**
|
|
8
|
-
* Extracts per-test inline configuration overrides from the NatSpec comments
|
|
9
|
-
* in the solc AST. It only extracts them from the build info where each
|
|
10
|
-
* test artifact's file was compiled as a root file.
|
|
11
|
-
*/
|
|
12
|
-
export declare function getTestFunctionOverrides(testSuiteArtifacts: EdrArtifactWithMetadata[], buildInfosAndOutputs: BuildInfoAndOutput[]): Promise<TestFunctionOverride[]>;
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/builtin-plugins/solidity-test/inline-config/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAc,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAoB7E,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,0BAA0B,EAC1B,cAAc,EACd,qBAAqB,GACtB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAQ1D;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,kBAAkB,EAAE,uBAAuB,EAAE,EAC7C,oBAAoB,EAAE,kBAAkB,EAAE,GACzC,OAAO,CAAC,oBAAoB,EAAE,CAAC,CASjC"}
|