hardhat 3.1.10 → 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 +26 -0
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/artifact-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/artifacts/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts +3 -5
- package/dist/src/internal/builtin-plugins/coverage/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers.js +7 -19
- package/dist/src/internal/builtin-plugins/coverage/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js +42 -0
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/test.js.map +1 -0
- package/dist/src/internal/builtin-plugins/coverage/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/index.js +1 -0
- package/dist/src/internal/builtin-plugins/coverage/index.js.map +1 -1
- 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 +8 -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 +20 -18
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts +7 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js +42 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.js.map +1 -0
- package/dist/src/internal/builtin-plugins/gas-analytics/index.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/index.js +36 -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/network-manager/edr/edr-provider.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +17 -20
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.js +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.d.ts +0 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.js +0 -6
- package/dist/src/internal/builtin-plugins/network-manager/edr/type-validation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts +1 -3
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js +0 -49
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-results.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-results.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-results.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.d.ts +1 -0
- 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 +13 -5
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.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/dependency-graph.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/dependency-graph.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts +2 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts +13 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js +30 -5
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts +3 -12
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/types.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.d.ts +8 -6
- 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 +103 -27
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js +5 -0
- package/dist/src/internal/builtin-plugins/solidity/hook-handlers/hre.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.js +1 -1
- package/dist/src/internal/builtin-plugins/solidity/tasks/build.js.map +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/edr-artifacts.d.ts +1 -1
- 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/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 +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/runner.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/runner.js +3 -3
- 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 +21 -27
- 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/telemetry/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/telemetry/task-action.js +3 -2
- package/dist/src/internal/builtin-plugins/telemetry/task-action.js.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 +62 -13
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts +27 -0
- package/dist/src/internal/builtin-plugins/test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/cli/banner-manager.d.ts +26 -0
- package/dist/src/internal/cli/banner-manager.d.ts.map +1 -0
- package/dist/src/internal/cli/banner-manager.js +146 -0
- package/dist/src/internal/cli/banner-manager.js.map +1 -0
- package/dist/src/internal/cli/init/init.d.ts.map +1 -1
- package/dist/src/internal/cli/init/init.js +8 -0
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +18 -1
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/subprocess.js +2 -0
- package/dist/src/internal/cli/telemetry/analytics/subprocess.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymize-paths.js +1 -1
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.d.ts +1 -1
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.js +47 -38
- package/dist/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.js +1 -1
- package/dist/src/types/artifacts.d.ts +32 -3
- package/dist/src/types/artifacts.d.ts.map +1 -1
- package/dist/src/types/network.d.ts +1 -1
- package/dist/src/types/solidity/build-system.d.ts +56 -10
- package/dist/src/types/solidity/build-system.d.ts.map +1 -1
- package/dist/src/types/solidity/build-system.js +26 -2
- package/dist/src/types/solidity/build-system.js.map +1 -1
- package/dist/src/types/solidity/resolved-file.d.ts +2 -2
- package/dist/src/types/tasks.d.ts +8 -0
- package/dist/src/types/tasks.d.ts.map +1 -1
- package/dist/src/types/tasks.js.map +1 -1
- package/dist/src/types/test.d.ts +18 -0
- package/dist/src/types/test.d.ts.map +1 -1
- package/dist/src/types/utils.d.ts +16 -0
- package/dist/src/types/utils.d.ts.map +1 -1
- package/dist/src/utils/result.d.ts +33 -0
- package/dist/src/utils/result.d.ts.map +1 -0
- package/dist/src/utils/result.js +43 -0
- package/dist/src/utils/result.js.map +1 -0
- package/package.json +6 -5
- package/src/internal/builtin-plugins/artifacts/artifact-manager.ts +4 -1
- package/src/internal/builtin-plugins/artifacts/hook-handlers/hre.ts +4 -1
- package/src/internal/builtin-plugins/coverage/helpers.ts +11 -29
- package/src/internal/builtin-plugins/coverage/hook-handlers/test.ts +68 -0
- package/src/internal/builtin-plugins/coverage/index.ts +1 -0
- 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 +38 -27
- package/src/internal/builtin-plugins/gas-analytics/hook-handlers/test.ts +68 -0
- package/src/internal/builtin-plugins/gas-analytics/index.ts +37 -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/network-manager/edr/edr-provider.ts +21 -28
- package/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-generation-errors.ts +5 -2
- package/src/internal/builtin-plugins/network-manager/edr/type-validation.ts +0 -13
- package/src/internal/builtin-plugins/network-manager/edr/utils/convert-to-edr.ts +0 -64
- package/src/internal/builtin-plugins/solidity/build-results.ts +3 -1
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +15 -5
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/dependency-graph.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/remapped-npm-packages-graph.ts +36 -6
- package/src/internal/builtin-plugins/solidity/build-system/resolver/types.ts +3 -9
- package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +1 -1
- package/src/internal/builtin-plugins/solidity/build-system/solc-config-selection.ts +125 -28
- package/src/internal/builtin-plugins/solidity/config.ts +2 -2
- package/src/internal/builtin-plugins/solidity/hook-handlers/hre.ts +8 -0
- package/src/internal/builtin-plugins/solidity/tasks/build.ts +1 -1
- package/src/internal/builtin-plugins/solidity-test/config.ts +15 -0
- package/src/internal/builtin-plugins/solidity-test/edr-artifacts.ts +2 -2
- 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 +3 -3
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +47 -40
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +17 -10
- package/src/internal/builtin-plugins/telemetry/task-action.ts +4 -2
- package/src/internal/builtin-plugins/test/task-action.ts +88 -24
- package/src/internal/builtin-plugins/test/type-extensions.ts +42 -0
- package/src/internal/cli/banner-manager.ts +234 -0
- package/src/internal/cli/init/init.ts +8 -0
- package/src/internal/cli/main.ts +19 -1
- package/src/internal/cli/telemetry/analytics/subprocess.ts +2 -0
- package/src/internal/cli/telemetry/sentry/anonymize-paths.ts +1 -1
- package/src/internal/cli/telemetry/sentry/vendor/integrations/contextlines.ts +98 -50
- package/src/internal/core/user-interruptions.ts +1 -1
- package/src/types/artifacts.ts +40 -3
- package/src/types/hre.ts +1 -1
- package/src/types/network.ts +1 -1
- package/src/types/solidity/build-system.ts +75 -14
- package/src/types/solidity/resolved-file.ts +2 -2
- package/src/types/tasks.ts +10 -0
- package/src/types/test.ts +20 -0
- package/src/types/utils.ts +14 -0
- package/src/utils/result.ts +57 -0
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +9 -9
- package/templates/hardhat-3/02-mocha-ethers/package.json +10 -10
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.d.ts +0 -19
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.d.ts.map +0 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.js +0 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/types/output.js.map +0 -1
- package/src/internal/builtin-plugins/network-manager/edr/types/output.ts +0 -19
|
@@ -18,19 +18,17 @@ export class SolcConfigSelector {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Creates a new SolcConfigSelector that can be used to select the best solc
|
|
21
|
-
* configuration for subgraphs
|
|
21
|
+
* configuration for single-root subgraphs to create their respective
|
|
22
|
+
* individual compilation jobs.
|
|
22
23
|
*
|
|
23
|
-
* All the queries
|
|
24
|
-
* using the same build profile.
|
|
24
|
+
* All the queries use the same build profile.
|
|
25
25
|
*
|
|
26
26
|
* @param buildProfileName The name of the build profile to use.
|
|
27
27
|
* @param buildProfile The build profile config.
|
|
28
|
-
* @param _dependencyGraph The entire dependency graph of the project.
|
|
29
28
|
*/
|
|
30
29
|
constructor(
|
|
31
30
|
buildProfileName: string,
|
|
32
31
|
buildProfile: SolidityBuildProfileConfig,
|
|
33
|
-
_dependencyGraph: DependencyGraph,
|
|
34
32
|
) {
|
|
35
33
|
this.#buildProfileName = buildProfileName;
|
|
36
34
|
this.#buildProfile = buildProfile;
|
|
@@ -46,7 +44,7 @@ export class SolcConfigSelector {
|
|
|
46
44
|
*/
|
|
47
45
|
public selectBestSolcConfigForSingleRootGraph(
|
|
48
46
|
subgraph: DependencyGraph,
|
|
49
|
-
): SolcConfig | CompilationJobCreationError {
|
|
47
|
+
): { success: true; config: SolcConfig } | CompilationJobCreationError {
|
|
50
48
|
const roots = subgraph.getRoots();
|
|
51
49
|
|
|
52
50
|
assertHardhatInvariant(
|
|
@@ -56,11 +54,11 @@ export class SolcConfigSelector {
|
|
|
56
54
|
|
|
57
55
|
const [userSourceName, root] = [...roots.entries()][0];
|
|
58
56
|
|
|
59
|
-
const
|
|
57
|
+
const allVersionPragmas = [...subgraph.getAllFiles()]
|
|
60
58
|
.map(({ content }) => content.versionPragmas)
|
|
61
59
|
.flat(1);
|
|
62
60
|
|
|
63
|
-
const versionRange = Array.from(new Set(
|
|
61
|
+
const versionRange = Array.from(new Set(allVersionPragmas)).join(" ");
|
|
64
62
|
|
|
65
63
|
const overriddenCompiler = this.#buildProfile.overrides[userSourceName];
|
|
66
64
|
|
|
@@ -75,7 +73,7 @@ export class SolcConfigSelector {
|
|
|
75
73
|
);
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
return overriddenCompiler;
|
|
76
|
+
return { success: true, config: overriddenCompiler };
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
// if there's no override, we find a compiler that matches the version range
|
|
@@ -100,9 +98,21 @@ export class SolcConfigSelector {
|
|
|
100
98
|
`Matching config not found for version '${matchingVersion.toString()}'`,
|
|
101
99
|
);
|
|
102
100
|
|
|
103
|
-
return matchingConfig;
|
|
101
|
+
return { success: true, config: matchingConfig };
|
|
104
102
|
}
|
|
105
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Returns a description of why we couldn't get a compiler configuration for
|
|
106
|
+
* the given root file and dependency subgraph.
|
|
107
|
+
*
|
|
108
|
+
* @param root The root file that created the single-root dependency subgraph
|
|
109
|
+
* @param dependencyGraph The dependency subgraph we couldn't get a compiler
|
|
110
|
+
* configuration for
|
|
111
|
+
* @param compilerVersions The compiler versions that are configured for the
|
|
112
|
+
* selected build profile. For overridden roots, it's a single one.
|
|
113
|
+
* @param overridden True if the root has an overridden config.
|
|
114
|
+
* @returns The error why we couldn't get a compiler configuration.
|
|
115
|
+
*/
|
|
106
116
|
#getCompilationJobCreationError(
|
|
107
117
|
root: ResolvedFile,
|
|
108
118
|
dependencyGraph: DependencyGraph,
|
|
@@ -110,27 +120,70 @@ export class SolcConfigSelector {
|
|
|
110
120
|
overridden: boolean,
|
|
111
121
|
): CompilationJobCreationError {
|
|
112
122
|
const rootVersionRange = root.content.versionPragmas.join(" ");
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
|
|
124
|
+
// This logic is pretty different depending if we are dealing with a config
|
|
125
|
+
// override or not. If we are, we have a single compiler option, so things
|
|
126
|
+
// are simpler.
|
|
127
|
+
|
|
128
|
+
if (overridden) {
|
|
129
|
+
// The root may not be compatible with the override version
|
|
130
|
+
if (maxSatisfying(compilerVersions, rootVersionRange) === null) {
|
|
131
|
+
return {
|
|
132
|
+
success: false,
|
|
133
|
+
reason:
|
|
134
|
+
CompilationJobCreationErrorReason.INCOMPATIBLE_OVERRIDDEN_SOLC_VERSION,
|
|
135
|
+
rootFilePath: root.fsPath,
|
|
136
|
+
buildProfile: this.#buildProfileName,
|
|
137
|
+
formattedReason: `An override with incompatible solc version was found for this file.`,
|
|
138
|
+
};
|
|
124
139
|
}
|
|
125
140
|
|
|
141
|
+
// A transitive dependency can have a pragma that's incompatible with
|
|
142
|
+
// the overridden version.
|
|
143
|
+
for (const transitiveDependency of this.#getTransitiveDependencies(
|
|
144
|
+
root,
|
|
145
|
+
dependencyGraph,
|
|
146
|
+
)) {
|
|
147
|
+
const depOwnRange =
|
|
148
|
+
transitiveDependency.dependency.content.versionPragmas.join(" ");
|
|
149
|
+
|
|
150
|
+
if (maxSatisfying(compilerVersions, depOwnRange) === null) {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
reason:
|
|
154
|
+
CompilationJobCreationErrorReason.OVERRIDDEN_SOLC_VERSION_INCOMPATIBLE_WITH_DEPENDENCY,
|
|
155
|
+
rootFilePath: root.fsPath,
|
|
156
|
+
buildProfile: this.#buildProfileName,
|
|
157
|
+
incompatibleImportPath: transitiveDependency.fsPath,
|
|
158
|
+
formattedReason: `The compiler version override is incompatible with a dependency of this file:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// There's no other case. If the root and all the dependencies are
|
|
164
|
+
// compatible, and we still can choose a version, we have a bug.
|
|
165
|
+
/* c8 ignore next 5 */
|
|
166
|
+
assertHardhatInvariant(
|
|
167
|
+
false,
|
|
168
|
+
"Trying to get the error for an overridden solidity file that has no compatible config, but failed to detect it, as the root and all the dependencies are compatible with the overridden compiler config.",
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Non-overridden case: we first check if the root is compatible with any
|
|
173
|
+
// configured compiler
|
|
174
|
+
if (maxSatisfying(compilerVersions, rootVersionRange) === null) {
|
|
126
175
|
return {
|
|
127
|
-
|
|
176
|
+
success: false,
|
|
177
|
+
reason:
|
|
178
|
+
CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_WITH_ROOT,
|
|
128
179
|
rootFilePath: root.fsPath,
|
|
129
180
|
buildProfile: this.#buildProfileName,
|
|
130
|
-
formattedReason
|
|
181
|
+
formattedReason: `No solc version enabled in this profile is compatible with this file.`,
|
|
131
182
|
};
|
|
132
183
|
}
|
|
133
184
|
|
|
185
|
+
// We check all the transitive dependencies of the root to try to return
|
|
186
|
+
// the most specific error that we can.
|
|
134
187
|
for (const transitiveDependency of this.#getTransitiveDependencies(
|
|
135
188
|
root,
|
|
136
189
|
dependencyGraph,
|
|
@@ -140,21 +193,59 @@ export class SolcConfigSelector {
|
|
|
140
193
|
.map((pragmas) => pragmas.join(" "))
|
|
141
194
|
.join(" ");
|
|
142
195
|
|
|
196
|
+
const depOwnRange =
|
|
197
|
+
transitiveDependency.dependency.content.versionPragmas.join(" ");
|
|
198
|
+
|
|
199
|
+
// A transitive dependency can have a pragma that's incompatible with
|
|
200
|
+
// all the configured compilers
|
|
201
|
+
if (maxSatisfying(compilerVersions, depOwnRange) === null) {
|
|
202
|
+
return {
|
|
203
|
+
success: false,
|
|
204
|
+
reason:
|
|
205
|
+
CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_WITH_DEPENDENCY,
|
|
206
|
+
rootFilePath: root.fsPath,
|
|
207
|
+
buildProfile: this.#buildProfileName,
|
|
208
|
+
incompatibleImportPath: transitiveDependency.fsPath,
|
|
209
|
+
formattedReason: `No solc version enabled in this profile is compatible with a dependency of this file:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// The root and the version ranges to get to this transitive dependency
|
|
214
|
+
// may be contradictory, so no version ever can satisfy them.
|
|
143
215
|
if (!intersects(rootVersionRange, transitiveDependencyVersionRange)) {
|
|
144
216
|
return {
|
|
217
|
+
success: false,
|
|
145
218
|
reason: CompilationJobCreationErrorReason.IMPORT_OF_INCOMPATIBLE_FILE,
|
|
146
219
|
rootFilePath: root.fsPath,
|
|
147
220
|
buildProfile: this.#buildProfileName,
|
|
148
221
|
incompatibleImportPath: transitiveDependency.fsPath,
|
|
149
|
-
formattedReason: `Following these imports leads to an incompatible solc version pragma that no version can satisfy
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
222
|
+
formattedReason: `Following these imports leads to an incompatible solc version pragma that no version can satisfy:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The root and the version ranges to get to this transitive dependency
|
|
227
|
+
// may not be compatible with any configured compiler.
|
|
228
|
+
const combinedRange = `${rootVersionRange} ${transitiveDependencyVersionRange}`;
|
|
229
|
+
if (maxSatisfying(compilerVersions, combinedRange) === null) {
|
|
230
|
+
return {
|
|
231
|
+
success: false,
|
|
232
|
+
reason:
|
|
233
|
+
CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_FOR_TRANSITIVE_IMPORT_PATH,
|
|
234
|
+
rootFilePath: root.fsPath,
|
|
235
|
+
buildProfile: this.#buildProfileName,
|
|
236
|
+
incompatibleImportPath: transitiveDependency.fsPath,
|
|
237
|
+
formattedReason: `No solc version enabled in this profile is compatible with this file and this import path:\n * ${shortenPath(root.fsPath)}\n * ${transitiveDependency.fsPath.map((s) => shortenPath(s)).join("\n * ")}`,
|
|
153
238
|
};
|
|
154
239
|
}
|
|
155
240
|
}
|
|
156
241
|
|
|
242
|
+
// This is a generic case that can happen when the incompatibilities exist
|
|
243
|
+
// but we can't detect them with the above algorithm. For example, if a
|
|
244
|
+
// root imports two compatible dependencies that are incompatible with each
|
|
245
|
+
// other. We could try and improve this error message, but it's
|
|
246
|
+
// computationally expensive and hard to express to the users.
|
|
157
247
|
return {
|
|
248
|
+
success: false,
|
|
158
249
|
reason:
|
|
159
250
|
CompilationJobCreationErrorReason.NO_COMPATIBLE_SOLC_VERSION_FOUND,
|
|
160
251
|
rootFilePath: root.fsPath,
|
|
@@ -163,6 +254,12 @@ export class SolcConfigSelector {
|
|
|
163
254
|
};
|
|
164
255
|
}
|
|
165
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Returns a generator of all the transitive dependencies of a root file. For each
|
|
259
|
+
* dependency, it yields the sequence of fsPaths from the root to that dependency,
|
|
260
|
+
* along with the corresponding version pragma paths for each file in the import chain.
|
|
261
|
+
* The paths don't include the root itself.
|
|
262
|
+
*/
|
|
166
263
|
*#getTransitiveDependencies(
|
|
167
264
|
root: ResolvedFile,
|
|
168
265
|
dependencyGraph: DependencyGraph,
|
|
@@ -179,7 +276,7 @@ export class SolcConfigSelector {
|
|
|
179
276
|
continue;
|
|
180
277
|
}
|
|
181
278
|
|
|
182
|
-
visited
|
|
279
|
+
visited = new Set([...visited, file]);
|
|
183
280
|
|
|
184
281
|
yield {
|
|
185
282
|
fsPath: [file.fsPath],
|
|
@@ -124,7 +124,7 @@ const buildProfilesSolidityUserConfigType = commonSolidityUserConfigType.extend(
|
|
|
124
124
|
},
|
|
125
125
|
);
|
|
126
126
|
|
|
127
|
-
const
|
|
127
|
+
const solidityUserConfigType = conditionalUnionType(
|
|
128
128
|
[
|
|
129
129
|
[(data) => typeof data === "string", z.string()],
|
|
130
130
|
[(data) => Array.isArray(data), z.array(z.string()).nonempty()],
|
|
@@ -159,7 +159,7 @@ const userConfigType = z.object({
|
|
|
159
159
|
).optional(),
|
|
160
160
|
})
|
|
161
161
|
.optional(),
|
|
162
|
-
solidity:
|
|
162
|
+
solidity: solidityUserConfigType.optional(),
|
|
163
163
|
});
|
|
164
164
|
|
|
165
165
|
export function validateSolidityUserConfig(
|
|
@@ -46,6 +46,14 @@ class LazySolidityBuildSystem implements SolidityBuildSystem {
|
|
|
46
46
|
return buildSystem.getScope(fsPath);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
public isSuccessfulBuildResult(
|
|
50
|
+
buildResult: CompilationJobCreationError | Map<string, FileBuildResult>,
|
|
51
|
+
): buildResult is Map<string, FileBuildResult> {
|
|
52
|
+
// Note: This duplicates the logic of the actual implementation because it's
|
|
53
|
+
// a synchronous method, so we can't import the implementation.
|
|
54
|
+
return buildResult instanceof Map;
|
|
55
|
+
}
|
|
56
|
+
|
|
49
57
|
public async build(
|
|
50
58
|
rootFiles: string[],
|
|
51
59
|
options?: BuildOptions,
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
} from "../../../types/config.js";
|
|
7
7
|
import type { HardhatUserConfigValidationError } from "../../../types/hooks.js";
|
|
8
8
|
import type {
|
|
9
|
+
SolidityTestConfig,
|
|
9
10
|
SolidityTestForkingConfig,
|
|
10
11
|
SolidityTestUserConfig,
|
|
11
12
|
} from "../../../types/test.js";
|
|
@@ -22,6 +23,10 @@ import {
|
|
|
22
23
|
} from "@nomicfoundation/hardhat-zod-utils";
|
|
23
24
|
import { z } from "zod";
|
|
24
25
|
|
|
26
|
+
// the keccak256 of "built for ethereum"
|
|
27
|
+
export const DEFAULT_FUZZ_SEED =
|
|
28
|
+
"0x7727ea51af0441c20da14dcd68a15dac8c9ebd589c5be8fa8c87c1d3720450bc";
|
|
29
|
+
|
|
25
30
|
const solidityTestUserConfigType = z.object({
|
|
26
31
|
timeout: z.number().optional(),
|
|
27
32
|
fsPermissions: z
|
|
@@ -152,6 +157,7 @@ export async function resolveSolidityTestUserConfig(
|
|
|
152
157
|
const solidityTest = {
|
|
153
158
|
rpcCachePath: defaultRpcCachePath,
|
|
154
159
|
...userConfig.test?.solidity,
|
|
160
|
+
fuzz: resolveFuzzConfig(userConfig.test?.solidity?.fuzz),
|
|
155
161
|
forking: resolvedForking,
|
|
156
162
|
};
|
|
157
163
|
|
|
@@ -170,3 +176,12 @@ export async function resolveSolidityTestUserConfig(
|
|
|
170
176
|
},
|
|
171
177
|
};
|
|
172
178
|
}
|
|
179
|
+
|
|
180
|
+
export function resolveFuzzConfig(
|
|
181
|
+
fuzzUserConfig: SolidityTestUserConfig["fuzz"] = {},
|
|
182
|
+
): SolidityTestConfig["fuzz"] {
|
|
183
|
+
return {
|
|
184
|
+
...fuzzUserConfig,
|
|
185
|
+
seed: fuzzUserConfig.seed ?? DEFAULT_FUZZ_SEED,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
@@ -60,7 +60,7 @@ export async function getBuildInfos(
|
|
|
60
60
|
*/
|
|
61
61
|
export async function getEdrArtifacts(
|
|
62
62
|
artifactManager: ArtifactManager,
|
|
63
|
-
): Promise<Array<{
|
|
63
|
+
): Promise<Array<{ edrArtifact: EdrArtifact; userSourceName: string }>> {
|
|
64
64
|
const fullyQualifiedNames = await artifactManager.getAllFullyQualifiedNames();
|
|
65
65
|
|
|
66
66
|
const artifacts = await Promise.all(
|
|
@@ -140,7 +140,7 @@ export async function getEdrArtifacts(
|
|
|
140
140
|
// from an artifact id between the `run` call and the events emitted by the
|
|
141
141
|
// test runner.
|
|
142
142
|
return {
|
|
143
|
-
|
|
143
|
+
edrArtifact: {
|
|
144
144
|
id,
|
|
145
145
|
contract,
|
|
146
146
|
},
|
|
@@ -38,10 +38,6 @@ interface SolidityTestConfigParams {
|
|
|
38
38
|
generateGasReport: boolean;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function hexStringToBuffer(hexString: string): Buffer {
|
|
42
|
-
return Buffer.from(hexStringToBytes(hexString));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
41
|
export function solidityTestConfigToRunOptions(
|
|
46
42
|
config: SolidityTestConfig,
|
|
47
43
|
): RunOptions {
|
|
@@ -85,16 +81,12 @@ export async function solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
|
85
81
|
})) ?? [],
|
|
86
82
|
].flat(1);
|
|
87
83
|
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const blockCoinbase: Buffer | undefined =
|
|
95
|
-
config.coinbase === undefined
|
|
96
|
-
? undefined
|
|
97
|
-
: hexStringToBuffer(config.coinbase);
|
|
84
|
+
const hexToBytes = (hex: string | undefined) =>
|
|
85
|
+
hex !== undefined ? hexStringToBytes(hex) : undefined;
|
|
86
|
+
|
|
87
|
+
const sender = hexToBytes(config.from);
|
|
88
|
+
const txOrigin = hexToBytes(config.txOrigin);
|
|
89
|
+
const blockCoinbase = hexToBytes(config.coinbase);
|
|
98
90
|
|
|
99
91
|
const resolvedHardfork = hardhatHardforkToEdrSpecId(
|
|
100
92
|
resolveHardfork(hardfork, chainType),
|
|
@@ -38,13 +38,13 @@ export interface RunOptions {
|
|
|
38
38
|
* Despite the changes, the signature of the function should still be considered
|
|
39
39
|
* a draft that may change in the future.
|
|
40
40
|
*
|
|
41
|
-
* TODO: Once the signature is
|
|
41
|
+
* TODO: Once the signature is finalized, give feedback to the EDR team.
|
|
42
42
|
*/
|
|
43
43
|
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,12 +1,15 @@
|
|
|
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 { TestRunResult } from "../../../types/test.js";
|
|
5
|
+
import type { Result } from "../../../types/utils.js";
|
|
4
6
|
import type {
|
|
5
7
|
Artifact as EdrArtifact,
|
|
6
8
|
BuildInfoAndOutput,
|
|
7
9
|
ObservabilityConfig,
|
|
8
10
|
SolidityTestRunnerConfigArgs,
|
|
9
11
|
TracingConfigWithBuffers,
|
|
12
|
+
SuiteResult,
|
|
10
13
|
} from "@nomicfoundation/edr";
|
|
11
14
|
|
|
12
15
|
import { finished } from "node:stream/promises";
|
|
@@ -19,19 +22,10 @@ import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
|
|
|
19
22
|
import { createNonClosingWriter } from "@nomicfoundation/hardhat-utils/stream";
|
|
20
23
|
|
|
21
24
|
import { getFullyQualifiedName } from "../../../utils/contract-names.js";
|
|
25
|
+
import { errorResult, successfulResult } from "../../../utils/result.js";
|
|
22
26
|
import { HardhatRuntimeEnvironmentImplementation } from "../../core/hre.js";
|
|
23
27
|
import { isSupportedChainType } from "../../edr/chain-type.js";
|
|
24
28
|
import { ArtifactManagerImplementation } from "../artifacts/artifact-manager.js";
|
|
25
|
-
import {
|
|
26
|
-
markTestRunStart as initCoverage,
|
|
27
|
-
markTestWorkerDone as saveCoverageData,
|
|
28
|
-
markTestRunDone as reportCoverage,
|
|
29
|
-
} from "../coverage/helpers.js";
|
|
30
|
-
import {
|
|
31
|
-
markTestRunStart as initGasStats,
|
|
32
|
-
markTestWorkerDone as saveGasStatsData,
|
|
33
|
-
markTestRunDone as reportGasStats,
|
|
34
|
-
} from "../gas-analytics/helpers.js";
|
|
35
29
|
import { edrGasReportToHardhatGasMeasurements } from "../network-manager/edr/utils/convert-to-edr.js";
|
|
36
30
|
|
|
37
31
|
import { getEdrArtifacts, getBuildInfos } from "./edr-artifacts.js";
|
|
@@ -53,10 +47,14 @@ interface TestActionArguments {
|
|
|
53
47
|
testSummaryIndex: number;
|
|
54
48
|
}
|
|
55
49
|
|
|
50
|
+
export interface SolidityTestRunResult extends TestRunResult {
|
|
51
|
+
suiteResults: SuiteResult[];
|
|
52
|
+
}
|
|
53
|
+
|
|
56
54
|
const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
57
55
|
{ testFiles, chainType, grep, noCompile, verbosity, testSummaryIndex },
|
|
58
56
|
hre,
|
|
59
|
-
) => {
|
|
57
|
+
): Promise<Result<SolidityTestRunResult, SolidityTestRunResult>> => {
|
|
60
58
|
assertHardhatInvariant(
|
|
61
59
|
hre instanceof HardhatRuntimeEnvironmentImplementation,
|
|
62
60
|
"Expected HRE to be an instance of HardhatRuntimeEnvironmentImplementation",
|
|
@@ -98,7 +96,7 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
98
96
|
|
|
99
97
|
// EDR needs all artifacts (contracts + tests)
|
|
100
98
|
const edrArtifacts: Array<{
|
|
101
|
-
|
|
99
|
+
edrArtifact: EdrArtifact;
|
|
102
100
|
userSourceName: string;
|
|
103
101
|
}> = [];
|
|
104
102
|
const buildInfos: BuildInfoAndOutput[] = [];
|
|
@@ -110,20 +108,20 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
const sourceNameToUserSourceName = new Map(
|
|
113
|
-
edrArtifacts.map(({ userSourceName,
|
|
114
|
-
|
|
111
|
+
edrArtifacts.map(({ userSourceName, edrArtifact }) => [
|
|
112
|
+
edrArtifact.id.source,
|
|
115
113
|
userSourceName,
|
|
116
114
|
]),
|
|
117
115
|
);
|
|
118
116
|
|
|
119
|
-
edrArtifacts.forEach(({ userSourceName,
|
|
117
|
+
edrArtifacts.forEach(({ userSourceName, edrArtifact }) => {
|
|
120
118
|
if (
|
|
121
119
|
testRootPaths.includes(
|
|
122
120
|
resolveFromRoot(hre.config.paths.root, userSourceName),
|
|
123
121
|
) &&
|
|
124
|
-
isTestSuiteArtifact(
|
|
122
|
+
isTestSuiteArtifact(edrArtifact)
|
|
125
123
|
) {
|
|
126
|
-
warnDeprecatedTestFail(
|
|
124
|
+
warnDeprecatedTestFail(edrArtifact, sourceNameToUserSourceName);
|
|
127
125
|
}
|
|
128
126
|
});
|
|
129
127
|
|
|
@@ -133,8 +131,8 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
133
131
|
resolveFromRoot(hre.config.paths.root, userSourceName),
|
|
134
132
|
),
|
|
135
133
|
)
|
|
136
|
-
.filter(({
|
|
137
|
-
.map(({
|
|
134
|
+
.filter(({ edrArtifact }) => isTestSuiteArtifact(edrArtifact))
|
|
135
|
+
.map(({ edrArtifact }) => edrArtifact.id);
|
|
138
136
|
|
|
139
137
|
console.log("Running Solidity tests");
|
|
140
138
|
console.log();
|
|
@@ -168,7 +166,7 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
168
166
|
}
|
|
169
167
|
}
|
|
170
168
|
|
|
171
|
-
const
|
|
169
|
+
const testRunnerConfig: SolidityTestRunnerConfigArgs =
|
|
172
170
|
await solidityTestConfigToSolidityTestRunnerConfigArgs({
|
|
173
171
|
chainType,
|
|
174
172
|
projectRoot: hre.config.paths.root,
|
|
@@ -186,14 +184,18 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
186
184
|
const options: RunOptions =
|
|
187
185
|
solidityTestConfigToRunOptions(solidityTestConfig);
|
|
188
186
|
|
|
189
|
-
await
|
|
190
|
-
|
|
187
|
+
await hre.hooks.runHandlerChain(
|
|
188
|
+
"test",
|
|
189
|
+
"onTestRunStart",
|
|
190
|
+
["solidity"],
|
|
191
|
+
async () => {},
|
|
192
|
+
);
|
|
191
193
|
|
|
192
194
|
const runStream = run(
|
|
193
195
|
chainType,
|
|
194
|
-
edrArtifacts.map(({
|
|
196
|
+
edrArtifacts.map(({ edrArtifact }) => edrArtifact),
|
|
195
197
|
testSuiteIds,
|
|
196
|
-
|
|
198
|
+
testRunnerConfig,
|
|
197
199
|
tracingConfig,
|
|
198
200
|
sourceNameToUserSourceName,
|
|
199
201
|
options,
|
|
@@ -203,10 +205,11 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
203
205
|
let passed = 0;
|
|
204
206
|
let skipped = 0;
|
|
205
207
|
let failureOutput = "";
|
|
206
|
-
|
|
208
|
+
const suiteResults: SuiteResult[] = [];
|
|
207
209
|
const testReporterStream = runStream
|
|
208
210
|
.on("data", (event: TestEvent) => {
|
|
209
211
|
if (event.type === "suite:done") {
|
|
212
|
+
suiteResults.push(event.data);
|
|
210
213
|
if (event.data.testResults.some(({ status }) => status === "Failure")) {
|
|
211
214
|
includesFailures = true;
|
|
212
215
|
}
|
|
@@ -271,26 +274,30 @@ const runSolidityTests: NewTaskActionFunction<TestActionArguments> = async (
|
|
|
271
274
|
includesErrors = true;
|
|
272
275
|
}
|
|
273
276
|
|
|
274
|
-
await
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
await hre.hooks.runHandlerChain(
|
|
278
|
+
"test",
|
|
279
|
+
"onTestWorkerDone",
|
|
280
|
+
["solidity"],
|
|
281
|
+
async () => {},
|
|
282
|
+
);
|
|
280
283
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
await hre.hooks.runHandlerChain(
|
|
285
|
+
"test",
|
|
286
|
+
"onTestRunDone",
|
|
287
|
+
["solidity"],
|
|
288
|
+
async () => {},
|
|
289
|
+
);
|
|
284
290
|
|
|
285
291
|
console.log();
|
|
286
292
|
|
|
287
|
-
|
|
288
|
-
failed,
|
|
289
|
-
|
|
290
|
-
skipped,
|
|
291
|
-
todo: 0,
|
|
292
|
-
failureOutput,
|
|
293
|
+
const result = {
|
|
294
|
+
summary: { failed, passed, skipped, todo: 0, failureOutput },
|
|
295
|
+
suiteResults,
|
|
293
296
|
};
|
|
297
|
+
|
|
298
|
+
return includesFailures || includesErrors
|
|
299
|
+
? errorResult(result)
|
|
300
|
+
: successfulResult(result);
|
|
294
301
|
};
|
|
295
302
|
|
|
296
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 {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NewTaskActionFunction } from "../../../types/tasks.js";
|
|
2
2
|
|
|
3
|
+
import { errorResult, successfulResult } from "../../../utils/result.js";
|
|
3
4
|
import {
|
|
4
5
|
isTelemetryAllowed,
|
|
5
6
|
setTelemetryEnabled,
|
|
@@ -15,8 +16,7 @@ const configureTelemetry: NewTaskActionFunction<
|
|
|
15
16
|
> = async ({ enable, disable }) => {
|
|
16
17
|
if (enable && disable) {
|
|
17
18
|
console.error("Cannot enable and disable telemetry at the same time");
|
|
18
|
-
|
|
19
|
-
return;
|
|
19
|
+
return errorResult();
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (enable) {
|
|
@@ -40,6 +40,8 @@ const configureTelemetry: NewTaskActionFunction<
|
|
|
40
40
|
"Telemetry is disabled, to enable it run `npx hardhat telemetry --enable`",
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
return successfulResult();
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
export default configureTelemetry;
|