Skip to content

Commit 4868bad

Browse files
committed
update strict package in tests
1 parent 59b2e1a commit 4868bad

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

v-next/hardhat/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { getHRE } from "./internal/hre-singleton.js";
1+
import { getHardhatRuntimeEnvironmentSingleton } from "./internal/hre-singleton.js";
22

33
// TODO:
44
// - Load the config from the file system.
5-
const hre = await getHRE({});
5+
const hre = await getHardhatRuntimeEnvironmentSingleton({});
66

77
export const { config, tasks, globalArguments, hooks, interruptions } = hre;
88

v-next/hardhat/src/internal/cli/main.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Task } from "@nomicfoundation/hardhat-core/types/tasks";
1313

1414
import "tsx"; // NOTE: This is important, it allows us to load .ts files form the CLI
1515
import { builtinPlugins } from "../builtin-plugins/index.js";
16-
import { getHRE } from "../hre-singleton.js";
16+
import { getHardhatRuntimeEnvironmentSingleton } from "../hre-singleton.js";
1717

1818
export async function main(cliArguments: string[]) {
1919
const hreInitStart = performance.now();
@@ -84,10 +84,14 @@ export async function main(cliArguments: string[]) {
8484
usedCliArguments,
8585
);
8686

87-
const hre = await getHRE(userConfig, userProvidedGlobalArguments, {
88-
resolvedPlugins,
89-
globalParameterMap,
90-
});
87+
const hre = await getHardhatRuntimeEnvironmentSingleton(
88+
userConfig,
89+
userProvidedGlobalArguments,
90+
{
91+
resolvedPlugins,
92+
globalParameterMap,
93+
},
94+
);
9195

9296
const hreInitEnd = performance.now();
9397
console.log("Time to initialize the HRE (ms):", hreInitEnd - hreInitStart);

v-next/hardhat/src/internal/hre-singleton.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ let hre: HardhatRuntimeEnvironment;
88
* This function returns a singleton instance of the Hardhat Runtime Environment.
99
*
1010
* It exists so that the CLI and the programmatic API are always using the same HRE instance.
11+
*
12+
* Note: Only the params of the first call are used.
1113
*/
12-
export async function getHRE(
14+
export async function getHardhatRuntimeEnvironmentSingleton(
1315
...params: Parameters<typeof createHardhatRuntimeEnvironment>
1416
): Promise<HardhatRuntimeEnvironment> {
1517
if (hre === undefined) {

v-next/hardhat/test/hre/index.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
import assert from "node:assert";
1+
import assert from "node:assert/strict";
22
import { describe, it } from "node:test";
33

44
import { createHardhatRuntimeEnvironment } from "../../src/hre.js";
55
import { builtinPlugins } from "../../src/internal/builtin-plugins/index.js";
6-
import { getHRE } from "../../src/internal/hre-singleton.js";
6+
import { getHardhatRuntimeEnvironmentSingleton } from "../../src/internal/hre-singleton.js";
77

88
describe("HRE", () => {
99
describe("createHardhatRuntimeEnvironment", () => {
1010
it("should include the built-in plugins", async () => {
1111
const hre = await createHardhatRuntimeEnvironment({});
1212

13-
assert.deepStrictEqual(hre.config.plugins, builtinPlugins);
13+
assert.deepEqual(hre.config.plugins, builtinPlugins);
1414
});
1515
});
1616

17-
describe("getHRE", () => {
17+
describe("getHardhatRuntimeEnvironmentSingleton", () => {
1818
it("should return the same instance", async () => {
19-
const hre1 = await getHRE({ plugins: [{ id: "custom task" }] });
20-
const hre2 = await getHRE({});
19+
const hre1 = await getHardhatRuntimeEnvironmentSingleton({
20+
plugins: [{ id: "custom task" }],
21+
});
22+
const hre2 = await getHardhatRuntimeEnvironmentSingleton({});
2123

2224
assert.deepEqual(
2325
hre1.config.plugins.find((p) => p.id === "custom task"),
@@ -27,7 +29,7 @@ describe("HRE", () => {
2729
hre2.config.plugins.find((p) => p.id === "custom task"),
2830
{ id: "custom task" },
2931
);
30-
assert.deepStrictEqual(hre1, hre2);
32+
assert.deepEqual(hre1, hre2);
3133
});
3234
});
3335
});

0 commit comments

Comments
 (0)