hardhat 3.4.2 → 3.4.4
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 +37 -0
- package/dist/src/internal/builtin-plugins/console/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/console/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js +16 -16
- package/dist/src/internal/builtin-plugins/coverage/coverage-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js +1 -1
- package/dist/src/internal/builtin-plugins/coverage/helpers/accessors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js +2 -2
- package/dist/src/internal/builtin-plugins/coverage/hook-handlers/solidity.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js +7 -2
- package/dist/src/internal/builtin-plugins/coverage/instrumentation.js.map +1 -1
- package/dist/src/internal/builtin-plugins/coverage/process-coverage.js +6 -6
- package/dist/src/internal/builtin-plugins/coverage/process-coverage.js.map +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/flatten/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/flatten/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js +10 -10
- package/dist/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.js.map +1 -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 +12 -9
- package/dist/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/accessors.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js +2 -2
- package/dist/src/internal/builtin-plugins/gas-analytics/helpers/utils.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js +9 -9
- package/dist/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.js.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js +5 -5
- package/dist/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/edr-provider.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js +21 -24
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.js.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js +13 -11
- package/dist/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/artifacts/build-info-watcher.js +2 -2
- 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 +2 -1
- package/dist/src/internal/builtin-plugins/node/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/helpers.js +3 -3
- package/dist/src/internal/builtin-plugins/node/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/json-rpc/server.js +2 -2
- package/dist/src/internal/builtin-plugins/node/json-rpc/server.js.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/node/task-action.js +4 -4
- package/dist/src/internal/builtin-plugins/node/task-action.js.map +1 -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 +18 -9
- package/dist/src/internal/builtin-plugins/solidity/build-system/build-system.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts +8 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.d.ts.map +1 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js +46 -0
- package/dist/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.js.map +1 -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 +9 -3
- 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 +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js +2 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/index.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js +7 -19
- package/dist/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.js.map +1 -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/dependency-resolver.js +4 -3
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.d.ts +2 -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/resolver/utils.js +12 -8
- package/dist/src/internal/builtin-plugins/solidity/build-system/resolver/utils.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts +3 -2
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js +15 -6
- package/dist/src/internal/builtin-plugins/solidity/build-system/solc-info.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/config.d.ts.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/constants.d.ts +1 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity/constants.js +2 -0
- package/dist/src/internal/builtin-plugins/solidity/constants.js.map +1 -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 +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/config.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts +1 -2
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js +3 -3
- package/dist/src/internal/builtin-plugins/solidity-test/helpers.js.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts +2 -2
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/reporter.js +19 -17
- 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.map +1 -1
- package/dist/src/internal/builtin-plugins/solidity-test/task-action.js +5 -2
- 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 +1 -0
- package/dist/src/internal/builtin-plugins/solidity-test/type-extensions.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.d.ts.map +1 -1
- package/dist/src/internal/builtin-plugins/test/task-action.js +8 -6
- package/dist/src/internal/builtin-plugins/test/task-action.js.map +1 -1
- package/dist/src/internal/cli/banner-manager.js +2 -2
- package/dist/src/internal/cli/banner-manager.js.map +1 -1
- package/dist/src/internal/cli/error-handler.d.ts.map +1 -1
- package/dist/src/internal/cli/error-handler.js +6 -6
- package/dist/src/internal/cli/error-handler.js.map +1 -1
- package/dist/src/internal/cli/help/get-help-string.js +2 -2
- 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 +40 -28
- package/dist/src/internal/cli/init/init.js.map +1 -1
- package/dist/src/internal/cli/init/package-manager.d.ts.map +1 -1
- package/dist/src/internal/cli/init/package-manager.js +5 -5
- package/dist/src/internal/cli/init/package-manager.js.map +1 -1
- package/dist/src/internal/cli/init/prompt.d.ts.map +1 -1
- package/dist/src/internal/cli/init/prompt.js +3 -3
- package/dist/src/internal/cli/init/prompt.js.map +1 -1
- package/dist/src/internal/cli/main.d.ts.map +1 -1
- package/dist/src/internal/cli/main.js +2 -2
- package/dist/src/internal/cli/main.js.map +1 -1
- package/dist/src/internal/cli/node-version.js +1 -1
- package/dist/src/internal/cli/telemetry/analytics/analytics.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/analytics.js.map +1 -1
- package/dist/src/internal/cli/telemetry/analytics/utils.js +2 -2
- package/dist/src/internal/cli/telemetry/analytics/utils.js.map +1 -1
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts +58 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js +402 -0
- package/dist/src/internal/cli/telemetry/error-classification/classifier.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.d.ts +67 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.js +140 -0
- package/dist/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.d.ts +15 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.js +114 -0
- package/dist/src/internal/cli/telemetry/error-classification/filter.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.d.ts +52 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.d.ts.map +1 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.js +163 -0
- package/dist/src/internal/cli/telemetry/error-classification/helpers.js.map +1 -0
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js +2 -2
- package/dist/src/internal/cli/telemetry/error-reporter/global-error-handlers.js.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.js +14 -0
- package/dist/src/internal/cli/telemetry/error-reporter/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts +0 -2
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js +0 -117
- package/dist/src/internal/cli/telemetry/sentry/anonymizer.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/init.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/init.js +14 -9
- package/dist/src/internal/cli/telemetry/sentry/init.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.d.ts.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/reporter.js +3 -29
- package/dist/src/internal/cli/telemetry/sentry/reporter.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js +13 -19
- package/dist/src/internal/cli/telemetry/sentry/subprocess.js.map +1 -1
- package/dist/src/internal/cli/telemetry/sentry/transport.js +2 -2
- package/dist/src/internal/cli/telemetry/sentry/transport.js.map +1 -1
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js +2 -2
- package/dist/src/internal/cli/telemetry/telemetry-permissions.js.map +1 -1
- package/dist/src/internal/config-loading.js +2 -2
- package/dist/src/internal/config-loading.js.map +1 -1
- package/dist/src/internal/core/hook-manager.d.ts.map +1 -1
- package/dist/src/internal/core/hook-manager.js +10 -3
- package/dist/src/internal/core/hook-manager.js.map +1 -1
- package/dist/src/internal/core/user-interruptions.js +4 -4
- package/dist/src/internal/core/user-interruptions.js.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.d.ts.map +1 -1
- package/dist/src/internal/using-hardhat2-plugin-errors.js +2 -2
- package/dist/src/internal/using-hardhat2-plugin-errors.js.map +1 -1
- package/package.json +6 -9
- package/src/internal/builtin-plugins/console/task-action.ts +4 -4
- package/src/internal/builtin-plugins/coverage/coverage-manager.ts +21 -17
- package/src/internal/builtin-plugins/coverage/helpers/accessors.ts +1 -1
- package/src/internal/builtin-plugins/coverage/hook-handlers/solidity.ts +2 -2
- package/src/internal/builtin-plugins/coverage/instrumentation.ts +21 -2
- package/src/internal/builtin-plugins/coverage/process-coverage.ts +6 -6
- package/src/internal/builtin-plugins/flatten/task-action.ts +8 -4
- package/src/internal/builtin-plugins/gas-analytics/function-gas-snapshots.ts +11 -10
- package/src/internal/builtin-plugins/gas-analytics/gas-analytics-manager.ts +13 -9
- package/src/internal/builtin-plugins/gas-analytics/helpers/accessors.ts +1 -1
- package/src/internal/builtin-plugins/gas-analytics/helpers/utils.ts +2 -2
- package/src/internal/builtin-plugins/gas-analytics/snapshot-cheatcodes.ts +10 -9
- package/src/internal/builtin-plugins/gas-analytics/tasks/solidity-test/task-action.ts +11 -5
- package/src/internal/builtin-plugins/network-manager/edr/edr-provider.ts +2 -2
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-formatters.ts +23 -23
- package/src/internal/builtin-plugins/network-manager/edr/utils/trace-output.ts +14 -11
- package/src/internal/builtin-plugins/node/artifacts/build-info-watcher.ts +2 -2
- package/src/internal/builtin-plugins/node/helpers.ts +7 -4
- package/src/internal/builtin-plugins/node/json-rpc/server.ts +2 -2
- package/src/internal/builtin-plugins/node/task-action.ts +5 -4
- package/src/internal/builtin-plugins/solidity/build-system/build-system.ts +23 -9
- package/src/internal/builtin-plugins/solidity/build-system/compilation-job-cost.ts +61 -0
- package/src/internal/builtin-plugins/solidity/build-system/compiler/compiler.ts +17 -3
- package/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts +4 -2
- package/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts +2 -2
- package/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-wrapper.ts +19 -22
- package/src/internal/builtin-plugins/solidity/build-system/resolver/dependency-resolver.ts +9 -1
- package/src/internal/builtin-plugins/solidity/build-system/resolver/utils.ts +16 -7
- package/src/internal/builtin-plugins/solidity/build-system/solc-info.ts +27 -6
- package/src/internal/builtin-plugins/solidity/config.ts +5 -2
- package/src/internal/builtin-plugins/solidity/constants.ts +3 -0
- package/src/internal/builtin-plugins/solidity-test/config.ts +1 -0
- package/src/internal/builtin-plugins/solidity-test/helpers.ts +3 -4
- package/src/internal/builtin-plugins/solidity-test/reporter.ts +19 -18
- package/src/internal/builtin-plugins/solidity-test/task-action.ts +5 -2
- package/src/internal/builtin-plugins/solidity-test/type-extensions.ts +1 -0
- package/src/internal/builtin-plugins/test/task-action.ts +12 -6
- package/src/internal/cli/banner-manager.ts +2 -2
- package/src/internal/cli/error-handler.ts +10 -6
- package/src/internal/cli/help/get-help-string.ts +2 -2
- package/src/internal/cli/init/init.ts +53 -28
- package/src/internal/cli/init/package-manager.ts +8 -6
- package/src/internal/cli/init/prompt.ts +4 -3
- package/src/internal/cli/main.ts +4 -3
- package/src/internal/cli/node-version.ts +1 -1
- package/src/internal/cli/telemetry/analytics/analytics.ts +2 -2
- package/src/internal/cli/telemetry/analytics/utils.ts +2 -2
- package/src/internal/cli/telemetry/error-classification/classifier.ts +636 -0
- package/src/internal/cli/telemetry/error-classification/codebase-dependent-helpers.ts +200 -0
- package/src/internal/cli/telemetry/error-classification/filter.ts +140 -0
- package/src/internal/cli/telemetry/error-classification/helpers.ts +235 -0
- package/src/internal/cli/telemetry/error-reporter/global-error-handlers.ts +2 -2
- package/src/internal/cli/telemetry/error-reporter/reporter.ts +21 -0
- package/src/internal/cli/telemetry/sentry/anonymizer.ts +0 -168
- package/src/internal/cli/telemetry/sentry/init.ts +42 -33
- package/src/internal/cli/telemetry/sentry/reporter.ts +4 -47
- package/src/internal/cli/telemetry/sentry/subprocess.ts +13 -21
- package/src/internal/cli/telemetry/sentry/transport.ts +2 -2
- package/src/internal/cli/telemetry/telemetry-permissions.ts +2 -2
- package/src/internal/config-loading.ts +2 -2
- package/src/internal/core/hook-manager.ts +21 -3
- package/src/internal/core/user-interruptions.ts +4 -4
- package/src/internal/using-hardhat2-plugin-errors.ts +2 -2
- package/templates/hardhat-3/01-node-test-runner-viem/package.json +7 -7
- package/templates/hardhat-3/02-mocha-ethers/package.json +12 -12
- package/templates/hardhat-3/03-minimal/package.json +1 -1
- package/dist/src/internal/utils/colorizer.d.ts +0 -10
- package/dist/src/internal/utils/colorizer.d.ts.map +0 -1
- package/dist/src/internal/utils/colorizer.js +0 -2
- package/dist/src/internal/utils/colorizer.js.map +0 -1
- package/src/internal/utils/colorizer.ts +0 -9
|
@@ -7,7 +7,9 @@ import type {
|
|
|
7
7
|
import type { TableItem } from "@nomicfoundation/hardhat-utils/format";
|
|
8
8
|
|
|
9
9
|
import path from "node:path";
|
|
10
|
+
import { styleText } from "node:util";
|
|
10
11
|
|
|
12
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
11
13
|
import { formatTable } from "@nomicfoundation/hardhat-utils/format";
|
|
12
14
|
import {
|
|
13
15
|
ensureDir,
|
|
@@ -18,13 +20,11 @@ import {
|
|
|
18
20
|
writeJsonFile,
|
|
19
21
|
writeUtf8File,
|
|
20
22
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
21
|
-
import chalk from "chalk";
|
|
22
|
-
import debug from "debug";
|
|
23
23
|
|
|
24
24
|
import { getProcessedCoverageInfo } from "./process-coverage.js";
|
|
25
25
|
import { generateHtmlReport } from "./reports/html.js";
|
|
26
26
|
|
|
27
|
-
const log =
|
|
27
|
+
const log = createDebug("hardhat:core:coverage:coverage-manager");
|
|
28
28
|
|
|
29
29
|
const MAX_COLUMN_WIDTH = 80;
|
|
30
30
|
|
|
@@ -74,7 +74,7 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
74
74
|
/**
|
|
75
75
|
* @private exposed for testing purposes only
|
|
76
76
|
*/
|
|
77
|
-
public data:
|
|
77
|
+
public data: Map<string, number> = new Map();
|
|
78
78
|
|
|
79
79
|
readonly #coveragePath: string;
|
|
80
80
|
|
|
@@ -91,8 +91,8 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
public async addData(data: CoverageData): Promise<void> {
|
|
94
|
-
for (const
|
|
95
|
-
this.data.
|
|
94
|
+
for (const tag of data) {
|
|
95
|
+
this.data.set(tag, (this.data.get(tag) ?? 0) + 1);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
log("Added data", JSON.stringify(data, null, 2));
|
|
@@ -122,14 +122,14 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
122
122
|
public async clearData(id: string): Promise<void> {
|
|
123
123
|
const dataPath = await this.#getDataPath(id);
|
|
124
124
|
await remove(dataPath);
|
|
125
|
-
this.data =
|
|
125
|
+
this.data = new Map();
|
|
126
126
|
log("Cleared data from disk and memory");
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
public async saveData(id: string): Promise<void> {
|
|
130
130
|
const dataPath = await this.#getDataPath(id);
|
|
131
131
|
const filePath = path.join(dataPath, `${crypto.randomUUID()}.json`);
|
|
132
|
-
const data = this.data;
|
|
132
|
+
const data = Object.fromEntries(this.data);
|
|
133
133
|
await writeJsonFile(filePath, data);
|
|
134
134
|
log("Saved data", id, filePath);
|
|
135
135
|
}
|
|
@@ -170,15 +170,19 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
170
170
|
* @private exposed for testing purposes only
|
|
171
171
|
*/
|
|
172
172
|
public async loadData(...ids: string[]): Promise<void> {
|
|
173
|
-
this.data =
|
|
173
|
+
this.data = new Map();
|
|
174
|
+
|
|
174
175
|
for (const id of ids) {
|
|
175
176
|
const dataPath = await this.#getDataPath(id);
|
|
176
177
|
const filePaths = await getAllFilesMatching(dataPath);
|
|
178
|
+
|
|
177
179
|
for (const filePath of filePaths) {
|
|
178
|
-
const entries = await readJsonFile<
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
const entries = await readJsonFile<Record<string, number>>(filePath);
|
|
181
|
+
|
|
182
|
+
for (const [tag, count] of Object.entries(entries)) {
|
|
183
|
+
this.data.set(tag, (this.data.get(tag) ?? 0) + count);
|
|
181
184
|
}
|
|
185
|
+
|
|
182
186
|
log("Loaded data", id, filePath);
|
|
183
187
|
}
|
|
184
188
|
}
|
|
@@ -188,7 +192,7 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
188
192
|
* @private exposed for testing purposes only
|
|
189
193
|
*/
|
|
190
194
|
public async getReport(): Promise<Report> {
|
|
191
|
-
const allExecutedTags =
|
|
195
|
+
const allExecutedTags = this.data;
|
|
192
196
|
|
|
193
197
|
const reportPromises = Array.from(this.filesMetadata.entries()).map(
|
|
194
198
|
async ([fileRelativePath, fileStatements]) => {
|
|
@@ -435,18 +439,18 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
435
439
|
|
|
436
440
|
rows.push({
|
|
437
441
|
type: "title",
|
|
438
|
-
text:
|
|
442
|
+
text: styleText("bold", "Coverage Report"),
|
|
439
443
|
});
|
|
440
444
|
|
|
441
445
|
rows.push({
|
|
442
446
|
type: "section-header",
|
|
443
|
-
text:
|
|
447
|
+
text: styleText("bold", "File Coverage"),
|
|
444
448
|
});
|
|
445
449
|
|
|
446
450
|
rows.push({
|
|
447
451
|
type: "header",
|
|
448
452
|
cells: ["File Path", "Line %", "Statement %", "Uncovered Lines"].map(
|
|
449
|
-
(s) =>
|
|
453
|
+
(s) => styleText("yellow", s),
|
|
450
454
|
),
|
|
451
455
|
});
|
|
452
456
|
|
|
@@ -500,7 +504,7 @@ export class CoverageManagerImplementation implements CoverageManager {
|
|
|
500
504
|
rows.push({
|
|
501
505
|
type: "header",
|
|
502
506
|
cells: [
|
|
503
|
-
|
|
507
|
+
styleText("yellow", "Total"),
|
|
504
508
|
this.formatCoverage(totalLineCoverage),
|
|
505
509
|
this.formatCoverage(totalStatementCoverage),
|
|
506
510
|
"",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// handler and task-actions that may run on every `hardhat test` invocation
|
|
3
3
|
// regardless of whether the feature is enabled. It must stay lightweight:
|
|
4
4
|
// do not add top-level imports that pull in the coverage-manager module
|
|
5
|
-
// graph (
|
|
5
|
+
// graph (debug, node:crypto, file-system traversal, etc.), or the
|
|
6
6
|
// `--coverage` lazy-load is silently defeated for every caller.
|
|
7
7
|
// If a new helper needs a heavy dependency, put it in a sibling file
|
|
8
8
|
// (e.g. `helpers/utils.ts`) so the accessors file's import cost stays flat.
|
|
@@ -4,15 +4,15 @@ import type { CoverageMetadata } from "../types.js";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
|
|
6
6
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
7
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
7
8
|
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
8
9
|
import { readUtf8File } from "@nomicfoundation/hardhat-utils/fs";
|
|
9
10
|
import { findClosestPackageRoot } from "@nomicfoundation/hardhat-utils/package";
|
|
10
|
-
import debug from "debug";
|
|
11
11
|
|
|
12
12
|
import { getCoverageManager } from "../helpers/accessors.js";
|
|
13
13
|
import { instrumentSolidityFileForCompilationJob } from "../instrumentation.js";
|
|
14
14
|
|
|
15
|
-
const log =
|
|
15
|
+
const log = createDebug("hardhat:core:coverage:hook-handlers:solidity");
|
|
16
16
|
|
|
17
17
|
const COVERAGE_LIBRARY_PATH =
|
|
18
18
|
"__hardhat_coverage_library_a3e9cfe2-41b4-4a1f-ad9e-ac62dd82979e.sol";
|
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
addStatementCoverageInstrumentation,
|
|
5
5
|
latestSupportedSolidityVersion,
|
|
6
6
|
} from "@nomicfoundation/edr";
|
|
7
|
-
import {
|
|
7
|
+
import { assertHardhatInvariant } from "@nomicfoundation/hardhat-errors";
|
|
8
|
+
import {
|
|
9
|
+
lowerThanOrEqual,
|
|
10
|
+
parseVersion,
|
|
11
|
+
} from "@nomicfoundation/hardhat-utils/fast-semver";
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* Instruments a solidity source file as part of a compilation job. i.e. the
|
|
@@ -37,8 +41,23 @@ export function instrumentSolidityFileForCompilationJob({
|
|
|
37
41
|
instrumentationVersion: string;
|
|
38
42
|
} {
|
|
39
43
|
const latestSupportedVersion = latestSupportedSolidityVersion();
|
|
44
|
+
const parsedLatestSupportedVersion = parseVersion(latestSupportedVersion);
|
|
45
|
+
assertHardhatInvariant(
|
|
46
|
+
parsedLatestSupportedVersion !== undefined,
|
|
47
|
+
`Invalid latest supported solidity version: ${latestSupportedVersion}`,
|
|
48
|
+
);
|
|
40
49
|
let instrumentationVersion = compilationJobSolcVersion;
|
|
41
|
-
|
|
50
|
+
const parsedInstrumentationVersion = parseVersion(instrumentationVersion);
|
|
51
|
+
assertHardhatInvariant(
|
|
52
|
+
parsedInstrumentationVersion !== undefined,
|
|
53
|
+
`Invalid solc version: ${instrumentationVersion}`,
|
|
54
|
+
);
|
|
55
|
+
if (
|
|
56
|
+
!lowerThanOrEqual(
|
|
57
|
+
parsedInstrumentationVersion,
|
|
58
|
+
parsedLatestSupportedVersion,
|
|
59
|
+
)
|
|
60
|
+
) {
|
|
42
61
|
instrumentationVersion = latestSupportedVersion;
|
|
43
62
|
}
|
|
44
63
|
const { source, metadata } = addStatementCoverageInstrumentation(
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
Statement,
|
|
5
5
|
} from "./types.js";
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import { styleText } from "node:util";
|
|
8
8
|
|
|
9
9
|
// Use constants for the Uint8Array to improve memory usage (1 byte vs 8 bytes per item)
|
|
10
10
|
const STATUS_NOT_EXECUTED = 0; // equivalent to false
|
|
@@ -399,7 +399,7 @@ function printStatementsForDebugging(
|
|
|
399
399
|
console.debug(counter++ + " ---");
|
|
400
400
|
|
|
401
401
|
for (let i = statement.startUtf16; i < statement.endUtf16; i++) {
|
|
402
|
-
process.stdout.write(
|
|
402
|
+
process.stdout.write(styleText("gray", fileContent[i]));
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
console.debug();
|
|
@@ -413,7 +413,7 @@ function printStatementsForDebugging(
|
|
|
413
413
|
console.debug(counter++ + " ---");
|
|
414
414
|
|
|
415
415
|
for (let i = statement.startUtf16; i < statement.endUtf16; i++) {
|
|
416
|
-
process.stdout.write(
|
|
416
|
+
process.stdout.write(styleText("gray", fileContent[i]));
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
console.debug();
|
|
@@ -432,11 +432,11 @@ function printCharacterCoverageForDebugging(
|
|
|
432
432
|
): void {
|
|
433
433
|
for (let i = 0; i < characterCoverage.length; i++) {
|
|
434
434
|
if (characterCoverage[i] === STATUS_IGNORED) {
|
|
435
|
-
process.stdout.write(
|
|
435
|
+
process.stdout.write(styleText("gray", fileContent[i]));
|
|
436
436
|
} else if (characterCoverage[i] === STATUS_EXECUTED) {
|
|
437
|
-
process.stdout.write(
|
|
437
|
+
process.stdout.write(styleText("green", fileContent[i]));
|
|
438
438
|
} else {
|
|
439
|
-
process.stdout.write(
|
|
439
|
+
process.stdout.write(styleText("red", fileContent[i]));
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { NewTaskActionFunction } from "../../../types/tasks.js";
|
|
2
2
|
|
|
3
|
+
import { styleText } from "node:util";
|
|
4
|
+
|
|
3
5
|
import { resolveFromRoot } from "@nomicfoundation/hardhat-utils/path";
|
|
4
|
-
import chalk from "chalk";
|
|
5
6
|
|
|
6
7
|
import {
|
|
7
8
|
ResolvedFileType,
|
|
@@ -108,7 +109,8 @@ const flattenAction: NewTaskActionFunction<FlattenActionArguments> = async (
|
|
|
108
109
|
|
|
109
110
|
if (filesWithoutLicenses.length > 0) {
|
|
110
111
|
warn(
|
|
111
|
-
|
|
112
|
+
styleText(
|
|
113
|
+
"yellow",
|
|
112
114
|
`\nThe following file(s) do NOT specify SPDX licenses: ${filesWithoutLicenses.join(
|
|
113
115
|
", ",
|
|
114
116
|
)}`,
|
|
@@ -118,7 +120,8 @@ const flattenAction: NewTaskActionFunction<FlattenActionArguments> = async (
|
|
|
118
120
|
|
|
119
121
|
if (pragmaDirective !== "" && filesWithoutPragmaDirectives.length > 0) {
|
|
120
122
|
warn(
|
|
121
|
-
|
|
123
|
+
styleText(
|
|
124
|
+
"yellow",
|
|
122
125
|
`\nPragma abicoder directives are defined in some files, but they are not defined in the following ones: ${filesWithoutPragmaDirectives.join(
|
|
123
126
|
", ",
|
|
124
127
|
)}`,
|
|
@@ -128,7 +131,8 @@ const flattenAction: NewTaskActionFunction<FlattenActionArguments> = async (
|
|
|
128
131
|
|
|
129
132
|
if (filesWithDifferentPragmaDirectives.length > 0) {
|
|
130
133
|
warn(
|
|
131
|
-
|
|
134
|
+
styleText(
|
|
135
|
+
"yellow",
|
|
132
136
|
`\nThe flattened file is using the pragma abicoder directive '${pragmaDirective}' but these files have a different pragma abicoder directive: ${filesWithDifferentPragmaDirectives.join(
|
|
133
137
|
", ",
|
|
134
138
|
)}`,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SuiteResult } from "@nomicfoundation/edr";
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { styleText } from "node:util";
|
|
4
5
|
|
|
5
6
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
6
7
|
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
writeUtf8File,
|
|
11
12
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
12
13
|
import { findDuplicates } from "@nomicfoundation/hardhat-utils/lang";
|
|
13
|
-
import chalk from "chalk";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
getFullyQualifiedName,
|
|
@@ -388,7 +388,8 @@ export function logFunctionGasSnapshotsSection(
|
|
|
388
388
|
if (isFirstTimeWrite) {
|
|
389
389
|
logger();
|
|
390
390
|
logger(
|
|
391
|
-
|
|
391
|
+
styleText(
|
|
392
|
+
"green",
|
|
392
393
|
" No existing snapshots found. Function gas snapshots written successfully",
|
|
393
394
|
),
|
|
394
395
|
);
|
|
@@ -408,7 +409,7 @@ export function logFunctionGasSnapshotsSection(
|
|
|
408
409
|
"\n",
|
|
409
410
|
);
|
|
410
411
|
for (const line of addedLines) {
|
|
411
|
-
logger(
|
|
412
|
+
logger(styleText("green", ` + ${line}`));
|
|
412
413
|
}
|
|
413
414
|
}
|
|
414
415
|
|
|
@@ -419,7 +420,7 @@ export function logFunctionGasSnapshotsSection(
|
|
|
419
420
|
comparison.removed,
|
|
420
421
|
).split("\n");
|
|
421
422
|
for (const line of removedLines) {
|
|
422
|
-
logger(
|
|
423
|
+
logger(styleText("red", ` - ${line}`));
|
|
423
424
|
}
|
|
424
425
|
}
|
|
425
426
|
|
|
@@ -435,10 +436,10 @@ export function printFunctionGasSnapshotChanges(
|
|
|
435
436
|
const isLast = i === changes.length - 1;
|
|
436
437
|
|
|
437
438
|
logger(` ${change.contractNameOrFqn}#${change.functionSig}`);
|
|
438
|
-
logger(
|
|
439
|
+
logger(styleText("grey", ` (in ${change.source})`));
|
|
439
440
|
|
|
440
441
|
if (change.kind === "fuzz") {
|
|
441
|
-
logger(
|
|
442
|
+
logger(styleText("grey", ` Runs: ${change.runs}`));
|
|
442
443
|
}
|
|
443
444
|
|
|
444
445
|
const diff = change.actual - change.expected;
|
|
@@ -454,15 +455,15 @@ export function printFunctionGasSnapshotChanges(
|
|
|
454
455
|
|
|
455
456
|
// Color: green for decrease (improvement), red for increase (regression)
|
|
456
457
|
const formattedGasChange =
|
|
457
|
-
diff < 0 ?
|
|
458
|
+
diff < 0 ? styleText("green", gasChange) : styleText("red", gasChange);
|
|
458
459
|
|
|
459
460
|
const label = change.kind === "fuzz" ? "~" : "gas";
|
|
460
461
|
|
|
461
|
-
logger(
|
|
462
|
+
logger(styleText("grey", ` Expected (${label}): ${change.expected}`));
|
|
462
463
|
logger(
|
|
463
|
-
|
|
464
|
+
styleText("grey", ` Actual (${label}): ${change.actual} (`) +
|
|
464
465
|
formattedGasChange +
|
|
465
|
-
|
|
466
|
+
styleText("grey", ")"),
|
|
466
467
|
);
|
|
467
468
|
|
|
468
469
|
if (!isLast) {
|
|
@@ -10,11 +10,13 @@ import type { TableItem } from "@nomicfoundation/hardhat-utils/format";
|
|
|
10
10
|
|
|
11
11
|
import crypto from "node:crypto";
|
|
12
12
|
import path from "node:path";
|
|
13
|
+
import { styleText } from "node:util";
|
|
13
14
|
|
|
14
15
|
import {
|
|
15
16
|
HardhatError,
|
|
16
17
|
assertHardhatInvariant,
|
|
17
18
|
} from "@nomicfoundation/hardhat-errors";
|
|
19
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
18
20
|
import { formatTable } from "@nomicfoundation/hardhat-utils/format";
|
|
19
21
|
import {
|
|
20
22
|
ensureDir,
|
|
@@ -26,8 +28,6 @@ import {
|
|
|
26
28
|
writeJsonFile,
|
|
27
29
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
28
30
|
import { findDuplicates } from "@nomicfoundation/hardhat-utils/lang";
|
|
29
|
-
import chalk from "chalk";
|
|
30
|
-
import debug from "debug";
|
|
31
31
|
|
|
32
32
|
import { parseFullyQualifiedName } from "../../../utils/contract-names.js";
|
|
33
33
|
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
median,
|
|
42
42
|
} from "./helpers/utils.js";
|
|
43
43
|
|
|
44
|
-
const gasStatsLog =
|
|
44
|
+
const gasStatsLog = createDebug(
|
|
45
45
|
"hardhat:core:gas-analytics:gas-analytics-manager:gas-stats",
|
|
46
46
|
);
|
|
47
47
|
|
|
@@ -311,7 +311,10 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
|
|
|
311
311
|
const rows: TableItem[] = [];
|
|
312
312
|
|
|
313
313
|
if (gasStatsByContract.size > 0) {
|
|
314
|
-
rows.push({
|
|
314
|
+
rows.push({
|
|
315
|
+
type: "title",
|
|
316
|
+
text: styleText("bold", "Gas Usage Statistics"),
|
|
317
|
+
});
|
|
315
318
|
}
|
|
316
319
|
|
|
317
320
|
const sortedContracts = getSortedContractEntries(gasStatsByContract);
|
|
@@ -322,8 +325,9 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
|
|
|
322
325
|
} of sortedContracts) {
|
|
323
326
|
rows.push({
|
|
324
327
|
type: "section-header",
|
|
325
|
-
text:
|
|
326
|
-
subtitle:
|
|
328
|
+
text: styleText(["cyan", "bold"], userFqn),
|
|
329
|
+
subtitle:
|
|
330
|
+
proxyLabel !== undefined ? styleText("cyan", proxyLabel) : undefined,
|
|
327
331
|
});
|
|
328
332
|
|
|
329
333
|
if (contractGasStats.functions.size > 0) {
|
|
@@ -336,7 +340,7 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
|
|
|
336
340
|
"Median",
|
|
337
341
|
"Max",
|
|
338
342
|
"#calls",
|
|
339
|
-
].map((s) =>
|
|
343
|
+
].map((s) => styleText("yellow", s)),
|
|
340
344
|
});
|
|
341
345
|
}
|
|
342
346
|
|
|
@@ -372,7 +376,7 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
|
|
|
372
376
|
"Median",
|
|
373
377
|
"Max",
|
|
374
378
|
"#deployments",
|
|
375
|
-
].map((s) =>
|
|
379
|
+
].map((s) => styleText("yellow", s)),
|
|
376
380
|
});
|
|
377
381
|
rows.push({
|
|
378
382
|
type: "row",
|
|
@@ -388,7 +392,7 @@ export class GasAnalyticsManagerImplementation implements GasAnalyticsManager {
|
|
|
388
392
|
rows.push({
|
|
389
393
|
type: "header",
|
|
390
394
|
cells: [
|
|
391
|
-
|
|
395
|
+
styleText("yellow", "Bytecode size"),
|
|
392
396
|
`${contractGasStats.deployment.runtimeSize}`,
|
|
393
397
|
],
|
|
394
398
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// handler and task-actions that may run on every `hardhat test` invocation
|
|
3
3
|
// regardless of whether the feature is enabled. It must stay lightweight:
|
|
4
4
|
// do not add top-level imports that pull in the gas-analytics-manager module
|
|
5
|
-
// graph (
|
|
5
|
+
// graph (debug, node:crypto, file-system traversal, etc.), or the
|
|
6
6
|
// `--gas-stats` lazy-load is silently defeated for every caller.
|
|
7
7
|
// If a new helper needs a heavy dependency, put it in a sibling file
|
|
8
8
|
// (e.g. `helpers/utils.ts`) so the accessors file's import cost stays flat.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { styleText } from "node:util";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Converts an internal FQN (e.g. `"project/contracts/Foo.sol:Foo"` or
|
|
@@ -108,5 +108,5 @@ export function formatSectionHeader(
|
|
|
108
108
|
parts.push(`${removedLength} removed`);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
return `${sectionName}: ${
|
|
111
|
+
return `${sectionName}: ${styleText("gray", parts.join(", "))}`;
|
|
112
112
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SuiteResult } from "@nomicfoundation/edr";
|
|
2
2
|
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { styleText } from "node:util";
|
|
4
5
|
|
|
5
6
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
6
7
|
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
@@ -12,7 +13,6 @@ import {
|
|
|
12
13
|
remove,
|
|
13
14
|
writeJsonFile,
|
|
14
15
|
} from "@nomicfoundation/hardhat-utils/fs";
|
|
15
|
-
import chalk from "chalk";
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
getFullyQualifiedName,
|
|
@@ -371,7 +371,8 @@ export function logSnapshotCheatcodesSection(
|
|
|
371
371
|
if (isFirstTimeWrite) {
|
|
372
372
|
logger();
|
|
373
373
|
logger(
|
|
374
|
-
|
|
374
|
+
styleText(
|
|
375
|
+
"green",
|
|
375
376
|
" No existing snapshots found. Snapshot cheatcodes written successfully",
|
|
376
377
|
),
|
|
377
378
|
);
|
|
@@ -391,7 +392,7 @@ export function logSnapshotCheatcodesSection(
|
|
|
391
392
|
"\n",
|
|
392
393
|
);
|
|
393
394
|
for (const line of addedLines) {
|
|
394
|
-
logger(
|
|
395
|
+
logger(styleText("green", ` + ${line}`));
|
|
395
396
|
}
|
|
396
397
|
}
|
|
397
398
|
|
|
@@ -402,7 +403,7 @@ export function logSnapshotCheatcodesSection(
|
|
|
402
403
|
"\n",
|
|
403
404
|
);
|
|
404
405
|
for (const line of removedLines) {
|
|
405
|
-
logger(
|
|
406
|
+
logger(styleText("red", ` - ${line}`));
|
|
406
407
|
}
|
|
407
408
|
}
|
|
408
409
|
|
|
@@ -418,7 +419,7 @@ export function printSnapshotCheatcodeChanges(
|
|
|
418
419
|
const isLast = i === changes.length - 1;
|
|
419
420
|
|
|
420
421
|
logger(` ${change.group}#${change.name}`);
|
|
421
|
-
logger(
|
|
422
|
+
logger(styleText("grey", ` (in ${change.source})`));
|
|
422
423
|
|
|
423
424
|
const diff = change.actual - change.expected;
|
|
424
425
|
const formattedDiff = diff > 0 ? `Δ+${diff}` : `Δ${diff}`;
|
|
@@ -433,13 +434,13 @@ export function printSnapshotCheatcodeChanges(
|
|
|
433
434
|
|
|
434
435
|
// Color: green for decrease (improvement), red for increase (regression)
|
|
435
436
|
const formattedGasChange =
|
|
436
|
-
diff < 0 ?
|
|
437
|
+
diff < 0 ? styleText("green", gasChange) : styleText("red", gasChange);
|
|
437
438
|
|
|
438
|
-
logger(
|
|
439
|
+
logger(styleText("grey", ` Expected: ${change.expected}`));
|
|
439
440
|
logger(
|
|
440
|
-
|
|
441
|
+
styleText("grey", ` Actual: ${change.actual} (`) +
|
|
441
442
|
formattedGasChange +
|
|
442
|
-
|
|
443
|
+
styleText("grey", ")"),
|
|
443
444
|
);
|
|
444
445
|
|
|
445
446
|
if (!isLast) {
|
|
@@ -5,8 +5,9 @@ import type { FunctionGasSnapshotCheckResult } from "../../function-gas-snapshot
|
|
|
5
5
|
import type { SnapshotCheatcodesCheckResult } from "../../snapshot-cheatcodes.js";
|
|
6
6
|
import type { SuiteResult } from "@nomicfoundation/edr";
|
|
7
7
|
|
|
8
|
+
import { styleText } from "node:util";
|
|
9
|
+
|
|
8
10
|
import { HardhatError } from "@nomicfoundation/hardhat-errors";
|
|
9
|
-
import chalk from "chalk";
|
|
10
11
|
|
|
11
12
|
import { errorResult } from "../../../../../utils/result.js";
|
|
12
13
|
import {
|
|
@@ -103,7 +104,7 @@ export function logSnapshotResult(
|
|
|
103
104
|
logger: typeof console.log = console.log,
|
|
104
105
|
): void {
|
|
105
106
|
if (result.functionGasSnapshotsWritten) {
|
|
106
|
-
logger(
|
|
107
|
+
logger(styleText("green", "Function gas snapshots written successfully"));
|
|
107
108
|
logger();
|
|
108
109
|
}
|
|
109
110
|
}
|
|
@@ -133,8 +134,8 @@ export function logSnapshotCheckResult(
|
|
|
133
134
|
): void {
|
|
134
135
|
logger(
|
|
135
136
|
functionGasSnapshotsCheck.passed && snapshotCheatcodesCheck.passed
|
|
136
|
-
?
|
|
137
|
-
:
|
|
137
|
+
? styleText("green", "Snapshot check passed")
|
|
138
|
+
: styleText("red", "Snapshot check failed"),
|
|
138
139
|
);
|
|
139
140
|
|
|
140
141
|
const functionGasHasOutput =
|
|
@@ -164,7 +165,12 @@ export function logSnapshotCheckResult(
|
|
|
164
165
|
logSnapshotCheatcodesSection(snapshotCheatcodesCheck, logger);
|
|
165
166
|
|
|
166
167
|
if (!functionGasSnapshotsCheck.passed || !snapshotCheatcodesCheck.passed) {
|
|
167
|
-
logger(
|
|
168
|
+
logger(
|
|
169
|
+
styleText(
|
|
170
|
+
"yellow",
|
|
171
|
+
"To update snapshots, run your tests with --snapshot",
|
|
172
|
+
),
|
|
173
|
+
);
|
|
168
174
|
logger();
|
|
169
175
|
}
|
|
170
176
|
}
|
|
@@ -29,9 +29,9 @@ import {
|
|
|
29
29
|
HardhatError,
|
|
30
30
|
} from "@nomicfoundation/hardhat-errors";
|
|
31
31
|
import { toSeconds } from "@nomicfoundation/hardhat-utils/date";
|
|
32
|
+
import { createDebug } from "@nomicfoundation/hardhat-utils/debug";
|
|
32
33
|
import { ensureError } from "@nomicfoundation/hardhat-utils/error";
|
|
33
34
|
import { numberToHexString } from "@nomicfoundation/hardhat-utils/hex";
|
|
34
|
-
import debug from "debug";
|
|
35
35
|
|
|
36
36
|
import { sendErrorTelemetry } from "../../../cli/telemetry/error-reporter/reporter.js";
|
|
37
37
|
import { EDR_NETWORK_REVERT_SNAPSHOT_EVENT } from "../../../constants.js";
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
} from "./utils/convert-to-edr.js";
|
|
60
60
|
import { printLine, replaceLastLine } from "./utils/logger.js";
|
|
61
61
|
|
|
62
|
-
const log =
|
|
62
|
+
const log = createDebug("hardhat:core:network-manager:edr:provider");
|
|
63
63
|
|
|
64
64
|
interface EdrProviderConfig {
|
|
65
65
|
chainDescriptors: ChainDescriptorsConfig;
|