hardhat 3.2.0 → 3.3.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 +34 -0
- package/dist/src/internal/builtin-global-options.d.ts.map +1 -1
- package/dist/src/internal/builtin-global-options.js +14 -1
- package/dist/src/internal/builtin-global-options.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts +0 -5
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js +12 -3
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.js +12 -2
- package/dist/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts +9 -3
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +65 -42
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.d.ts +11 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js +104 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/genesis-state.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts +6 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js +152 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts +19 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js +104 -0
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js.map +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js +8 -8
- package/dist/src/internal/builtin-plugins/network-manager/hook-handlers/network.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/http-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/http-provider.js +1 -0
- package/dist/src/internal/builtin-plugins/network-manager/http-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js +63 -7
- package/dist/src/internal/builtin-plugins/network-manager/network-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js +56 -33
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.d.ts +0 -3
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.js +9 -12
- package/dist/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.js +6 -2
- package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.js +4 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/artifacts.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +5 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js +86 -47
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/cache.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts +3 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js +24 -4
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.d.ts +16 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts +4 -2
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.js +247 -68
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/exports.d.ts +3 -0
- package/dist/src/internal/builtin-plugins/solidity/exports.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/exports.js +3 -0
- package/dist/src/internal/builtin-plugins/solidity/exports.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js +2 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.d.ts +4 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.js +7 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/solidity.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/index.js +1 -0
- package/dist/src/internal/builtin-plugins/solidity/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.d.ts +18 -0
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js +33 -0
- package/dist/src/internal/builtin-plugins/solidity/solidity-hooks.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts +201 -28
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/type-extensions.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/edr-artifacts.d.ts +12 -6
- 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 +9 -7
- 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 +1 -12
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.js +0 -150
- package/dist/src/internal/builtin-plugins/solidity-test/formatters.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +4 -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 +5 -9
- 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 -7
- package/dist/src/internal/builtin-plugins/solidity-test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js +20 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/constants.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts +24 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js +68 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/helpers.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts +13 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js +136 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/index.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts +19 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js +133 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/parsing.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts +10 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/types.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts +12 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js +81 -0
- package/dist/src/internal/builtin-plugins/solidity-test/inline-config/validation.js.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +5 -2
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.d.ts +0 -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 +21 -14
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/index.js +0 -7
- package/dist/src/internal/builtin-plugins/test/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts +0 -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 +1 -4
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.d.ts.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.js +1 -1
- package/dist/src/internal/cli/help/get-help-string.js.map +1 -1
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +1 -1
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
- package/dist/src/internal/cli/init/prompt.js +1 -7
- package/dist/src/internal/cli/init/prompt.js.map +1 -1
- package/dist/src/internal/core/hre.d.ts +2 -1
- package/dist/src/internal/core/hre.d.ts.map +1 -1
- package/dist/src/internal/core/hre.js +18 -0
- package/dist/src/internal/core/hre.js.map +1 -1
- package/dist/src/internal/core/plugins/detect-plugin-npm-dependency-problems.d.ts.map +1 -1
- package/dist/src/internal/core/plugins/detect-plugin-npm-dependency-problems.js +6 -1
- package/dist/src/internal/core/plugins/detect-plugin-npm-dependency-problems.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.d.ts.map +1 -1
- package/dist/src/internal/core/user-interruptions.js +2 -5
- package/dist/src/internal/core/user-interruptions.js.map +1 -1
- package/dist/src/internal/utils/colorizer.d.ts +10 -0
- package/dist/src/internal/utils/colorizer.d.ts.map +1 -0
- package/dist/src/internal/utils/colorizer.js +2 -0
- package/dist/src/internal/utils/colorizer.js.map +1 -0
- package/dist/src/internal/utils/package.d.ts.map +1 -1
- package/dist/src/internal/utils/package.js +1 -1
- package/dist/src/internal/utils/package.js.map +1 -1
- package/dist/src/types/global-options.d.ts +1 -0
- package/dist/src/types/global-options.d.ts.map +1 -1
- package/dist/src/types/hooks.d.ts +32 -0
- package/dist/src/types/hooks.d.ts.map +1 -1
- package/dist/src/types/solidity/compilation-job.d.ts +5 -5
- package/dist/src/types/solidity/compilation-job.d.ts.map +1 -1
- package/dist/src/types/solidity/solidity-artifacts.d.ts +15 -0
- package/dist/src/types/solidity/solidity-artifacts.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/internal/builtin-global-options.ts +15 -1
- package/src/internal/builtin-plugins/gas-analytics/helpers.ts +13 -3
- package/src/internal/builtin-plugins/network-manager/accounts/derive-private-keys.ts +25 -3
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +107 -56
- package/src/internal/builtin-plugins/network-manager/edr/genesis-state.ts +179 -0
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts +197 -0
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts +137 -0
- package/src/internal/builtin-plugins/network-manager/hook-handlers/hre.ts +1 -0
- package/src/internal/builtin-plugins/network-manager/hook-handlers/network.ts +8 -11
- package/src/internal/builtin-plugins/network-manager/http-provider.ts +1 -0
- package/src/internal/builtin-plugins/network-manager/network-manager.ts +83 -10
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers/accounts/local-accounts.ts +98 -34
- package/src/internal/builtin-plugins/network-manager/request-handlers/handlers-array.ts +10 -30
- package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +1 -2
- package/src/internal/builtin-plugins/node/helpers.ts +9 -2
- package/src/internal/builtin-plugins/solidity/build-system/artifacts.ts +7 -2
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +141 -65
- package/src/internal/builtin-plugins/solidity/build-system/cache.ts +1 -0
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job.ts +34 -7
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +1 -2
- package/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.ts +4 -2
- package/src/internal/builtin-plugins/solidity/config.ts +335 -110
- package/src/internal/builtin-plugins/solidity/exports.ts +2 -0
- package/src/internal/builtin-plugins/solidity/hook-handlers/config.ts +3 -0
- package/src/internal/builtin-plugins/solidity/hook-handlers/solidity.ts +9 -0
- package/src/internal/builtin-plugins/solidity/index.ts +1 -0
- package/src/internal/builtin-plugins/solidity/solidity-hooks.ts +53 -0
- package/src/internal/builtin-plugins/solidity/type-extensions.ts +258 -31
- package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +22 -10
- package/src/internal/builtin-plugins/solidity-test/formatters.ts +1 -213
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +8 -8
- package/src/internal/builtin-plugins/solidity-test/index.ts +0 -7
- package/src/internal/builtin-plugins/solidity-test/inline-config/constants.ts +21 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/helpers.ts +99 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/index.ts +272 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/parsing.ts +186 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/types.ts +9 -0
- package/src/internal/builtin-plugins/solidity-test/inline-config/validation.ts +122 -0
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +6 -6
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +42 -25
- package/src/internal/builtin-plugins/test/index.ts +0 -7
- package/src/internal/builtin-plugins/test/task-action.ts +1 -6
- package/src/internal/cli/help/get-help-string.ts +2 -2
- package/src/internal/cli/init/init.ts +1 -1
- package/src/internal/cli/init/prompt.ts +1 -14
- package/src/internal/core/hre.ts +33 -0
- package/src/internal/core/plugins/detect-plugin-npm-dependency-problems.ts +8 -1
- package/src/internal/core/user-interruptions.ts +3 -5
- package/src/internal/utils/colorizer.ts +9 -0
- package/src/internal/utils/package.ts +1 -2
- package/src/types/global-options.ts +1 -0
- package/src/types/hooks.ts +37 -0
- package/src/types/solidity/compilation-job.ts +5 -5
- package/src/types/solidity/solidity-artifacts.ts +16 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +5 -5
- package/templates/hardhat-3/02-mocha-ethers/package.json +11 -11
- package/templates/hardhat-3/03-minimal/package.json +1 -1
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { RawInlineOverride } from "./types.js";
|
|
2
|
+
|
|
3
|
+
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
4
|
+
import { isObject } from "@nomicfoundation/hardhat-utils/lang";
|
|
5
|
+
import {
|
|
6
|
+
kebabToCamelCase,
|
|
7
|
+
snakeToCamelCase,
|
|
8
|
+
} from "@nomicfoundation/hardhat-utils/string";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
HARDHAT_CONFIG_PREFIX,
|
|
12
|
+
FORGE_CONFIG_PREFIX,
|
|
13
|
+
TOP_LEVEL_KEYS,
|
|
14
|
+
} from "./constants.js";
|
|
15
|
+
import { getFunctionFqn } from "./helpers.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Extracts raw inline config overrides from a solc AST for a single source
|
|
19
|
+
* file.
|
|
20
|
+
*/
|
|
21
|
+
export function extractInlineConfigFromAst(
|
|
22
|
+
ast: unknown,
|
|
23
|
+
inputSourceName: string,
|
|
24
|
+
contractNames: Set<string>,
|
|
25
|
+
): RawInlineOverride[] {
|
|
26
|
+
if (!isObject(ast) || ast.nodeType !== "SourceUnit") {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const results: RawInlineOverride[] = [];
|
|
31
|
+
const nodes: unknown[] = Array.isArray(ast.nodes) ? ast.nodes : [];
|
|
32
|
+
for (const node of nodes) {
|
|
33
|
+
if (!isObject(node) || node.nodeType !== "ContractDefinition") {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const contractName = node.name;
|
|
38
|
+
if (typeof contractName !== "string") {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!contractNames.has(contractName)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const members: unknown[] = Array.isArray(node.nodes) ? node.nodes : [];
|
|
47
|
+
for (const member of members) {
|
|
48
|
+
if (!isObject(member) || member.nodeType !== "FunctionDefinition") {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const fnName = member.name;
|
|
53
|
+
if (
|
|
54
|
+
typeof fnName !== "string" ||
|
|
55
|
+
(!fnName.startsWith("test") && !fnName.startsWith("invariant"))
|
|
56
|
+
) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const fnSelector =
|
|
61
|
+
typeof member.functionSelector === "string"
|
|
62
|
+
? member.functionSelector
|
|
63
|
+
: undefined;
|
|
64
|
+
|
|
65
|
+
const docText = extractDocText(member.documentation);
|
|
66
|
+
if (docText === undefined) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (const line of docText.split("\n")) {
|
|
71
|
+
const parsed = parseInlineConfigLine(
|
|
72
|
+
line,
|
|
73
|
+
inputSourceName,
|
|
74
|
+
contractName,
|
|
75
|
+
fnName,
|
|
76
|
+
);
|
|
77
|
+
if (parsed !== undefined) {
|
|
78
|
+
parsed.functionSelector = fnSelector;
|
|
79
|
+
results.push(parsed);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return results;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Extracts the documentation text from a FunctionDefinition's documentation
|
|
90
|
+
* field, which can be a StructuredDocumentation node, a plain string, or null.
|
|
91
|
+
*/
|
|
92
|
+
export function extractDocText(doc: unknown): string | undefined {
|
|
93
|
+
if (
|
|
94
|
+
isObject(doc) &&
|
|
95
|
+
doc.nodeType === "StructuredDocumentation" &&
|
|
96
|
+
typeof doc.text === "string"
|
|
97
|
+
) {
|
|
98
|
+
return doc.text;
|
|
99
|
+
} else if (typeof doc === "string") {
|
|
100
|
+
return doc;
|
|
101
|
+
} else {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Parses a single line from a NatSpec comment and returns a RawInlineOverride
|
|
108
|
+
* if the line contains a valid inline config directive. The line must start
|
|
109
|
+
* with either "hardhat-config:" or "forge-config:", followed by a key=value pair.
|
|
110
|
+
* Returns undefined if the line does not contain an inline config directive.
|
|
111
|
+
*/
|
|
112
|
+
export function parseInlineConfigLine(
|
|
113
|
+
line: string,
|
|
114
|
+
inputSourceName: string,
|
|
115
|
+
contractName: string,
|
|
116
|
+
functionName: string,
|
|
117
|
+
): RawInlineOverride | undefined {
|
|
118
|
+
// Strip leading whitespace and optional leading '*' from NatSpec text.
|
|
119
|
+
// Solc's StructuredDocumentation.text has delimiters (///, /**, */) removed.
|
|
120
|
+
// For /// comments, text has leading whitespace; for /** */ blocks, interior
|
|
121
|
+
// lines may start with " * ". The regex handles both styles.
|
|
122
|
+
const trimmedLine = line.replace(/^\s*\*?\s*/, "");
|
|
123
|
+
const functionFqn = getFunctionFqn(
|
|
124
|
+
inputSourceName,
|
|
125
|
+
contractName,
|
|
126
|
+
functionName,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
let keyValueSegment: string;
|
|
130
|
+
|
|
131
|
+
if (trimmedLine.startsWith(HARDHAT_CONFIG_PREFIX)) {
|
|
132
|
+
keyValueSegment = trimmedLine.slice(HARDHAT_CONFIG_PREFIX.length).trim();
|
|
133
|
+
} else if (trimmedLine.startsWith(FORGE_CONFIG_PREFIX)) {
|
|
134
|
+
keyValueSegment = trimmedLine.slice(FORGE_CONFIG_PREFIX.length).trim();
|
|
135
|
+
} else {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const eqIndex = keyValueSegment.indexOf("=");
|
|
140
|
+
if (eqIndex === -1) {
|
|
141
|
+
throw new HardhatError(
|
|
142
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_SYNTAX,
|
|
143
|
+
{
|
|
144
|
+
line: trimmedLine,
|
|
145
|
+
functionFqn,
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const rawKey = keyValueSegment.slice(0, eqIndex).trim();
|
|
151
|
+
let parsedKey = rawKey;
|
|
152
|
+
const rawValue = keyValueSegment.slice(eqIndex + 1).trim();
|
|
153
|
+
|
|
154
|
+
// Detect profile prefix: if the first dot-segment is NOT a known top-level
|
|
155
|
+
// category, treat it as a profile name.
|
|
156
|
+
const firstDot = rawKey.indexOf(".");
|
|
157
|
+
if (firstDot !== -1) {
|
|
158
|
+
const firstSegment = rawKey.slice(0, firstDot);
|
|
159
|
+
if (!TOP_LEVEL_KEYS.includes(firstSegment)) {
|
|
160
|
+
// It's a profile. Validate it.
|
|
161
|
+
const profile = firstSegment;
|
|
162
|
+
if (profile !== "default") {
|
|
163
|
+
throw new HardhatError(
|
|
164
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_UNSUPPORTED_PROFILE,
|
|
165
|
+
{
|
|
166
|
+
profile,
|
|
167
|
+
functionFqn,
|
|
168
|
+
},
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
// Strip the "default." prefix
|
|
172
|
+
parsedKey = rawKey.slice(firstDot + 1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
parsedKey = snakeToCamelCase(kebabToCamelCase(parsedKey));
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
inputSourceName,
|
|
180
|
+
contractName,
|
|
181
|
+
functionName,
|
|
182
|
+
key: parsedKey,
|
|
183
|
+
rawKey,
|
|
184
|
+
rawValue,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface RawInlineOverride {
|
|
2
|
+
inputSourceName: string;
|
|
3
|
+
contractName: string;
|
|
4
|
+
functionName: string;
|
|
5
|
+
functionSelector?: string; // from AST, hex without 0x prefix
|
|
6
|
+
key: string; // parsed camelCase key, without profile prefix
|
|
7
|
+
rawKey: string; // original key as written by the user, for error messages
|
|
8
|
+
rawValue: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { RawInlineOverride } from "./types.js";
|
|
2
|
+
|
|
3
|
+
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
4
|
+
|
|
5
|
+
import { KEY_TYPES } from "./constants.js";
|
|
6
|
+
import { getFunctionFqn } from "./helpers.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validates a list of raw inline overrides, checking for:
|
|
10
|
+
* - Valid keys
|
|
11
|
+
* - No duplicate keys for the same function
|
|
12
|
+
* - Values of the expected type (numbers must be non-negative integers, booleans
|
|
13
|
+
* must be "true" or "false")
|
|
14
|
+
*
|
|
15
|
+
* Throws a HardhatError if any validation fails.
|
|
16
|
+
*/
|
|
17
|
+
export function validateInlineOverrides(overrides: RawInlineOverride[]): void {
|
|
18
|
+
const seen = new Set<string>();
|
|
19
|
+
|
|
20
|
+
for (const {
|
|
21
|
+
inputSourceName,
|
|
22
|
+
contractName,
|
|
23
|
+
functionName,
|
|
24
|
+
functionSelector,
|
|
25
|
+
rawKey,
|
|
26
|
+
rawValue,
|
|
27
|
+
key,
|
|
28
|
+
} of overrides) {
|
|
29
|
+
const functionFqn = getFunctionFqn(
|
|
30
|
+
inputSourceName,
|
|
31
|
+
contractName,
|
|
32
|
+
functionName,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Validate key
|
|
36
|
+
if (!Object.hasOwn(KEY_TYPES, key)) {
|
|
37
|
+
throw new HardhatError(
|
|
38
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_KEY,
|
|
39
|
+
{
|
|
40
|
+
key: rawKey,
|
|
41
|
+
validKeys: Object.keys(KEY_TYPES).join(", "),
|
|
42
|
+
functionFqn,
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Validate key matches test type
|
|
48
|
+
const dotIndex = key.indexOf(".");
|
|
49
|
+
if (dotIndex !== -1) {
|
|
50
|
+
const keyCategory = key.slice(0, dotIndex);
|
|
51
|
+
const isFuzzTest = functionName.startsWith("test");
|
|
52
|
+
const isInvariantTest = functionName.startsWith("invariant");
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
(isFuzzTest && keyCategory === "invariant") ||
|
|
56
|
+
(isInvariantTest && keyCategory === "fuzz")
|
|
57
|
+
) {
|
|
58
|
+
const testType = isFuzzTest ? "fuzz" : "invariant";
|
|
59
|
+
const validPrefix = isFuzzTest ? "fuzz." : "invariant.";
|
|
60
|
+
const validKeys = Object.keys(KEY_TYPES)
|
|
61
|
+
.filter((k) => k.startsWith(validPrefix) || !k.includes("."))
|
|
62
|
+
.join(", ");
|
|
63
|
+
|
|
64
|
+
throw new HardhatError(
|
|
65
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_KEY_FOR_TEST_TYPE,
|
|
66
|
+
{
|
|
67
|
+
key: rawKey,
|
|
68
|
+
functionFqn,
|
|
69
|
+
testType,
|
|
70
|
+
validKeys,
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check for duplicates (include selector to allow same key on overloaded functions)
|
|
77
|
+
const functionId =
|
|
78
|
+
functionSelector !== undefined
|
|
79
|
+
? `${functionFqn}#${functionSelector}`
|
|
80
|
+
: functionFqn;
|
|
81
|
+
const dedupeKey = `${functionId}-${key}`;
|
|
82
|
+
if (seen.has(dedupeKey)) {
|
|
83
|
+
throw new HardhatError(
|
|
84
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_DUPLICATE_KEY,
|
|
85
|
+
{ key: rawKey, functionFqn },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
seen.add(dedupeKey);
|
|
89
|
+
|
|
90
|
+
// Validate value type
|
|
91
|
+
const expectedType = KEY_TYPES[key];
|
|
92
|
+
if (expectedType === "number") {
|
|
93
|
+
if (
|
|
94
|
+
!/^(0|[1-9]\d*)$/.test(rawValue) ||
|
|
95
|
+
!Number.isSafeInteger(Number(rawValue))
|
|
96
|
+
) {
|
|
97
|
+
throw new HardhatError(
|
|
98
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_VALUE,
|
|
99
|
+
{
|
|
100
|
+
value: rawValue,
|
|
101
|
+
key: rawKey,
|
|
102
|
+
expectedType: "non-negative integer",
|
|
103
|
+
functionFqn,
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
const lowerValue = rawValue.toLowerCase();
|
|
109
|
+
if (lowerValue !== "true" && lowerValue !== "false") {
|
|
110
|
+
throw new HardhatError(
|
|
111
|
+
HardhatError.ERRORS.CORE.SOLIDITY_TESTS.INLINE_CONFIG_INVALID_VALUE,
|
|
112
|
+
{
|
|
113
|
+
value: rawValue,
|
|
114
|
+
key: rawKey,
|
|
115
|
+
expectedType: "boolean",
|
|
116
|
+
functionFqn,
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
TestReporterResult,
|
|
4
4
|
TestStatus,
|
|
5
5
|
} from "./types.js";
|
|
6
|
+
import type { Colorizer } from "../../utils/colorizer.js";
|
|
6
7
|
import type { TestResult } from "@nomicfoundation/edr";
|
|
7
8
|
|
|
8
9
|
import { bytesToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
@@ -11,12 +12,9 @@ import chalk from "chalk";
|
|
|
11
12
|
import { sendErrorTelemetry } from "../../cli/telemetry/sentry/reporter.js";
|
|
12
13
|
import { SolidityTestStackTraceGenerationError } from "../network-manager/edr/stack-traces/stack-trace-generation-errors.js";
|
|
13
14
|
import { encodeStackTraceEntry } from "../network-manager/edr/stack-traces/stack-trace-solidity-errors.js";
|
|
15
|
+
import { formatTraces } from "../network-manager/edr/utils/trace-formatters.js";
|
|
14
16
|
|
|
15
|
-
import {
|
|
16
|
-
type Colorizer,
|
|
17
|
-
formatArtifactId,
|
|
18
|
-
formatTraces,
|
|
19
|
-
} from "./formatters.js";
|
|
17
|
+
import { formatArtifactId } from "./formatters.js";
|
|
20
18
|
import { getMessageFromLastStackTraceEntry } from "./stack-trace-solidity-errors.js";
|
|
21
19
|
|
|
22
20
|
class Indenter {
|
|
@@ -147,6 +145,8 @@ export async function* testReporter(
|
|
|
147
145
|
suiteSuccessCount++;
|
|
148
146
|
if (verbosity >= 5) {
|
|
149
147
|
printSetUpTraces = true;
|
|
148
|
+
}
|
|
149
|
+
if (verbosity >= 4) {
|
|
150
150
|
printExecutionTraces = true;
|
|
151
151
|
}
|
|
152
152
|
break;
|
|
@@ -184,7 +184,7 @@ export async function* testReporter(
|
|
|
184
184
|
if (printSetUpTraces && functionName === "setUp") {
|
|
185
185
|
return true;
|
|
186
186
|
}
|
|
187
|
-
if (printExecutionTraces && functionName !== "setUp
|
|
187
|
+
if (printExecutionTraces && functionName !== "setUp") {
|
|
188
188
|
return true;
|
|
189
189
|
}
|
|
190
190
|
return false;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BuildInfoAndOutput,
|
|
3
|
+
EdrArtifactWithMetadata,
|
|
4
|
+
} from "./edr-artifacts.js";
|
|
2
5
|
import type { TestEvent } from "./types.js";
|
|
3
6
|
import type { NewTaskActionFunction } from "../../../types/tasks.js";
|
|
4
7
|
import type { TestRunResult } from "../../../types/test.js";
|
|
5
8
|
import type { Result } from "../../../types/utils.js";
|
|
6
9
|
import type {
|
|
7
|
-
Artifact as EdrArtifact,
|
|
8
|
-
BuildInfoAndOutput,
|
|
9
10
|
ObservabilityConfig,
|
|
10
|
-
SolidityTestRunnerConfigArgs,
|
|
11
11
|
TracingConfigWithBuffers,
|
|
12
12
|
SuiteResult,
|
|
13
13
|
} from "@nomicfoundation/edr";
|
|
@@ -26,13 +26,17 @@ import { getCoverageManager } from "../coverage/helpers.js";
|
|
|
26
26
|
import { getGasAnalyticsManager } from "../gas-analytics/helpers.js";
|
|
27
27
|
import { edrGasReportToHardhatGasMeasurements } from "../network-manager/edr/utils/convert-to-edr.js";
|
|
28
28
|
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
buildEdrArtifactsWithMetadata,
|
|
31
|
+
getBuildInfosAndOutputs,
|
|
32
|
+
} from "./edr-artifacts.js";
|
|
30
33
|
import {
|
|
31
34
|
isTestSuiteArtifact,
|
|
32
35
|
warnDeprecatedTestFail,
|
|
33
36
|
solidityTestConfigToRunOptions,
|
|
34
37
|
solidityTestConfigToSolidityTestRunnerConfigArgs,
|
|
35
38
|
} from "./helpers.js";
|
|
39
|
+
import { getTestFunctionOverrides } from "./inline-config/index.js";
|
|
36
40
|
import { testReporter } from "./reporter.js";
|
|
37
41
|
import { run } from "./runner.js";
|
|
38
42
|
|
|
@@ -41,7 +45,6 @@ interface TestActionArguments {
|
|
|
41
45
|
chainType: string;
|
|
42
46
|
grep?: string;
|
|
43
47
|
noCompile: boolean;
|
|
44
|
-
verbosity: number;
|
|
45
48
|
testSummaryIndex: number;
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -50,12 +53,14 @@ export interface SolidityTestRunResult extends TestRunResult {
|
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
53
|
-
{ testFiles, chainType, grep, noCompile,
|
|
56
|
+
{ testFiles, chainType, grep, noCompile, testSummaryIndex },
|
|
54
57
|
hre,
|
|
55
58
|
): Promise<Result<SolidityTestRunResult, SolidityTestRunResult>> => {
|
|
56
59
|
// Set an environment variable that plugins can use to detect when a process is running tests
|
|
57
60
|
process.env.HH_TEST = "true";
|
|
58
61
|
|
|
62
|
+
const verbosity = hre.globalOptions.verbosity;
|
|
63
|
+
|
|
59
64
|
// Sets the NODE_ENV environment variable to "test" so the code can detect that tests are running
|
|
60
65
|
// This is done by other JS/TS test frameworks like vitest
|
|
61
66
|
process.env.NODE_ENV ??= "test";
|
|
@@ -88,26 +93,27 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
88
93
|
console.log();
|
|
89
94
|
|
|
90
95
|
// EDR needs all artifacts (contracts + tests)
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
userSourceName: string;
|
|
94
|
-
}> = [];
|
|
95
|
-
const buildInfos: BuildInfoAndOutput[] = [];
|
|
96
|
+
const edrArtifactsWithMetadata: EdrArtifactWithMetadata[] = [];
|
|
97
|
+
const allBuildInfosAndOutputs: BuildInfoAndOutput[] = [];
|
|
96
98
|
for (const scope of ["contracts", "tests"] as const) {
|
|
97
99
|
const artifactsDir = await hre.solidity.getArtifactsDirectory(scope);
|
|
98
100
|
const artifactManager = new ArtifactManagerImplementation(artifactsDir);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
edrArtifactsWithMetadata.push(
|
|
102
|
+
...(await buildEdrArtifactsWithMetadata(artifactManager)),
|
|
103
|
+
);
|
|
104
|
+
allBuildInfosAndOutputs.push(
|
|
105
|
+
...(await getBuildInfosAndOutputs(artifactManager)),
|
|
106
|
+
);
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
const sourceNameToUserSourceName = new Map(
|
|
104
|
-
|
|
110
|
+
edrArtifactsWithMetadata.map(({ userSourceName, edrArtifact }) => [
|
|
105
111
|
edrArtifact.id.source,
|
|
106
112
|
userSourceName,
|
|
107
113
|
]),
|
|
108
114
|
);
|
|
109
115
|
|
|
110
|
-
|
|
116
|
+
edrArtifactsWithMetadata.forEach(({ userSourceName, edrArtifact }) => {
|
|
111
117
|
if (
|
|
112
118
|
testRootPaths.includes(
|
|
113
119
|
resolveFromRoot(hre.config.paths.root, userSourceName),
|
|
@@ -118,14 +124,17 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
118
124
|
}
|
|
119
125
|
});
|
|
120
126
|
|
|
121
|
-
const
|
|
127
|
+
const testSuiteArtifacts = edrArtifactsWithMetadata
|
|
122
128
|
.filter(({ userSourceName }) =>
|
|
123
129
|
testRootPaths.includes(
|
|
124
130
|
resolveFromRoot(hre.config.paths.root, userSourceName),
|
|
125
131
|
),
|
|
126
132
|
)
|
|
127
|
-
.filter(({ edrArtifact }) => isTestSuiteArtifact(edrArtifact))
|
|
128
|
-
|
|
133
|
+
.filter(({ edrArtifact }) => isTestSuiteArtifact(edrArtifact));
|
|
134
|
+
|
|
135
|
+
const testSuiteIds = testSuiteArtifacts.map(
|
|
136
|
+
({ edrArtifact }) => edrArtifact.id,
|
|
137
|
+
);
|
|
129
138
|
|
|
130
139
|
console.log("Running Solidity tests");
|
|
131
140
|
console.log();
|
|
@@ -160,7 +169,12 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
160
169
|
}
|
|
161
170
|
}
|
|
162
171
|
|
|
163
|
-
const
|
|
172
|
+
const testFunctionOverrides = getTestFunctionOverrides(
|
|
173
|
+
testSuiteArtifacts,
|
|
174
|
+
allBuildInfosAndOutputs,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const testRunnerConfig =
|
|
164
178
|
await solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
165
179
|
chainType,
|
|
166
180
|
projectRoot: hre.config.paths.root,
|
|
@@ -172,13 +186,16 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
172
186
|
generateGasReport:
|
|
173
187
|
hre.globalOptions.gasStats ||
|
|
174
188
|
hre.globalOptions.gasStatsJson !== undefined,
|
|
189
|
+
testFunctionOverrides,
|
|
175
190
|
});
|
|
176
191
|
const tracingConfig: TracingConfigWithBuffers = {
|
|
177
|
-
buildInfos,
|
|
192
|
+
buildInfos: allBuildInfosAndOutputs.map(({ buildInfo, output }) => ({
|
|
193
|
+
buildInfo,
|
|
194
|
+
output,
|
|
195
|
+
})),
|
|
178
196
|
ignoreContracts: false,
|
|
179
197
|
};
|
|
180
|
-
const
|
|
181
|
-
solidityTestConfigToRunOptions(solidityTestConfig);
|
|
198
|
+
const runOptions = solidityTestConfigToRunOptions(solidityTestConfig);
|
|
182
199
|
|
|
183
200
|
await hre.hooks.runHandlerChain(
|
|
184
201
|
"test",
|
|
@@ -189,12 +206,12 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
189
206
|
|
|
190
207
|
const runStream = run(
|
|
191
208
|
chainType,
|
|
192
|
-
|
|
209
|
+
edrArtifactsWithMetadata.map(({ edrArtifact }) => edrArtifact),
|
|
193
210
|
testSuiteIds,
|
|
194
211
|
testRunnerConfig,
|
|
195
212
|
tracingConfig,
|
|
196
213
|
sourceNameToUserSourceName,
|
|
197
|
-
|
|
214
|
+
runOptions,
|
|
198
215
|
);
|
|
199
216
|
|
|
200
217
|
let failed = 0;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { HardhatPlugin } from "../../../types/plugins.js";
|
|
2
2
|
|
|
3
3
|
import { ArgumentType } from "../../../types/arguments.js";
|
|
4
|
-
import { DEFAULT_VERBOSITY } from "../../constants.js";
|
|
5
4
|
import { task } from "../../core/config.js";
|
|
6
5
|
|
|
7
6
|
import "./type-extensions.js";
|
|
@@ -33,12 +32,6 @@ const hardhatPlugin: HardhatPlugin = {
|
|
|
33
32
|
name: "noCompile",
|
|
34
33
|
description: "Do not compile the project before running the tests",
|
|
35
34
|
})
|
|
36
|
-
.addLevel({
|
|
37
|
-
name: "verbosity",
|
|
38
|
-
shortName: "v",
|
|
39
|
-
description: "Verbosity level of the test output",
|
|
40
|
-
defaultValue: DEFAULT_VERBOSITY,
|
|
41
|
-
})
|
|
42
35
|
.setAction(async () => import("./task-action.js"))
|
|
43
36
|
.build(),
|
|
44
37
|
],
|
|
@@ -24,7 +24,6 @@ interface TestActionArguments {
|
|
|
24
24
|
chainType: string;
|
|
25
25
|
grep: string | undefined;
|
|
26
26
|
noCompile: boolean;
|
|
27
|
-
verbosity: number;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
// Old plugins may only return { failed, passed } without skipped/todo,
|
|
@@ -51,7 +50,7 @@ function isTestRunResult(
|
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
54
|
-
{ testFiles, chainType, grep, noCompile,
|
|
53
|
+
{ testFiles, chainType, grep, noCompile, ...otherArgs },
|
|
55
54
|
hre,
|
|
56
55
|
): Promise<Result<void, void>> => {
|
|
57
56
|
// If this code is executed, it means the user has not specified a test runner.
|
|
@@ -107,10 +106,6 @@ const runAllTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
107
106
|
args.chainType = chainType;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
|
-
if (subtask.options.has("verbosity")) {
|
|
111
|
-
args.verbosity = verbosity;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
109
|
for (const [key, value] of Object.entries(otherArgs)) {
|
|
115
110
|
if (subtask.options.has(key)) {
|
|
116
111
|
args[key] = value;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { GlobalOptionDefinitions } from "../../../types/global-options.js";
|
|
2
2
|
import type { Task } from "../../../types/tasks.js";
|
|
3
3
|
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
7
|
GLOBAL_NAME_PADDING,
|
|
6
8
|
parseOptions,
|
|
@@ -15,8 +17,6 @@ export async function getHelpString(
|
|
|
15
17
|
task: Task,
|
|
16
18
|
globalOptionDefinitions: GlobalOptionDefinitions,
|
|
17
19
|
): Promise<string> {
|
|
18
|
-
const { default: chalk } = await import("chalk");
|
|
19
|
-
|
|
20
20
|
const { options, positionalArguments } = parseOptions(task);
|
|
21
21
|
|
|
22
22
|
const subtasks = parseSubtasks(task);
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
getHardhatVersion,
|
|
30
30
|
getLatestHardhatVersion,
|
|
31
31
|
} from "../../utils/package.js";
|
|
32
|
+
import { BannerManager } from "../banner-manager.js";
|
|
32
33
|
import { sendProjectTypeAnalytics } from "../telemetry/analytics/analytics.js";
|
|
33
34
|
import { sendErrorTelemetry } from "../telemetry/sentry/reporter.js";
|
|
34
35
|
|
|
@@ -133,7 +134,6 @@ export async function initHardhat(options?: InitHardhatOptions): Promise<void> {
|
|
|
133
134
|
showStarOnGitHubMessage();
|
|
134
135
|
|
|
135
136
|
try {
|
|
136
|
-
const { BannerManager } = await import("../banner-manager.js");
|
|
137
137
|
const bannerManager = await BannerManager.getInstance();
|
|
138
138
|
await bannerManager.showBanner();
|
|
139
139
|
} catch (bannerError) {
|
|
@@ -3,14 +3,13 @@ import type { Template } from "./template.js";
|
|
|
3
3
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
4
4
|
import { shortenPath } from "@nomicfoundation/hardhat-utils/path";
|
|
5
5
|
import chalk from "chalk";
|
|
6
|
+
import enquirer from "enquirer";
|
|
6
7
|
|
|
7
8
|
export async function promptForHardhatVersion(): Promise<
|
|
8
9
|
"hardhat-2" | "hardhat-3"
|
|
9
10
|
> {
|
|
10
11
|
ensureTTY();
|
|
11
12
|
|
|
12
|
-
const { default: enquirer } = await import("enquirer");
|
|
13
|
-
|
|
14
13
|
const hardhatVersionResponse = await enquirer.prompt<{
|
|
15
14
|
hardhatVersion: "hardhat-2" | "hardhat-3";
|
|
16
15
|
}>([
|
|
@@ -40,8 +39,6 @@ export async function promptForHardhatVersion(): Promise<
|
|
|
40
39
|
export async function promptForWorkspace(): Promise<string> {
|
|
41
40
|
ensureTTY();
|
|
42
41
|
|
|
43
|
-
const { default: enquirer } = await import("enquirer");
|
|
44
|
-
|
|
45
42
|
const workspaceResponse = await enquirer.prompt<{ workspace: string }>([
|
|
46
43
|
{
|
|
47
44
|
name: "workspace",
|
|
@@ -59,8 +56,6 @@ export async function promptForMigrateToEsm(
|
|
|
59
56
|
): Promise<boolean> {
|
|
60
57
|
ensureTTY();
|
|
61
58
|
|
|
62
|
-
const { default: enquirer } = await import("enquirer");
|
|
63
|
-
|
|
64
59
|
const migrateToEsmResponse = await enquirer.prompt<{ migrateToEsm: boolean }>(
|
|
65
60
|
[
|
|
66
61
|
{
|
|
@@ -80,8 +75,6 @@ export async function promptForTemplate(
|
|
|
80
75
|
): Promise<string> {
|
|
81
76
|
ensureTTY();
|
|
82
77
|
|
|
83
|
-
const { default: enquirer } = await import("enquirer");
|
|
84
|
-
|
|
85
78
|
const templateResponse = await enquirer.prompt<{ template: string }>([
|
|
86
79
|
{
|
|
87
80
|
name: "template",
|
|
@@ -102,8 +95,6 @@ export async function promptForTemplate(
|
|
|
102
95
|
export async function promptForForce(files: string[]): Promise<boolean> {
|
|
103
96
|
ensureTTY();
|
|
104
97
|
|
|
105
|
-
const { default: enquirer } = await import("enquirer");
|
|
106
|
-
|
|
107
98
|
const forceResponse = await enquirer.prompt<{ force: boolean }>([
|
|
108
99
|
{
|
|
109
100
|
name: "force",
|
|
@@ -121,8 +112,6 @@ export async function promptForInstall(
|
|
|
121
112
|
): Promise<boolean> {
|
|
122
113
|
ensureTTY();
|
|
123
114
|
|
|
124
|
-
const { default: enquirer } = await import("enquirer");
|
|
125
|
-
|
|
126
115
|
const installResponse = await enquirer.prompt<{ install: boolean }>([
|
|
127
116
|
{
|
|
128
117
|
name: "install",
|
|
@@ -140,8 +129,6 @@ export async function promptForUpdate(
|
|
|
140
129
|
): Promise<boolean> {
|
|
141
130
|
ensureTTY();
|
|
142
131
|
|
|
143
|
-
const { default: enquirer } = await import("enquirer");
|
|
144
|
-
|
|
145
132
|
const updateResponse = await enquirer.prompt<{ update: boolean }>([
|
|
146
133
|
{
|
|
147
134
|
name: "update",
|