Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/edr-0.26.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Upgraded EDR to v0.26.0.
5 changes: 5 additions & 0 deletions .changeset/edr-estimate-gas-fork-hardfork.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @anaPerezGhiglia! Fixed `eth_estimateGas` over-estimating at historical blocks on forked chains whose hardfork differs from the configured one.
5 changes: 5 additions & 0 deletions .changeset/edr-fork-chain-id-fee-params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @anaPerezGhiglia! Fixed blocks mined on a fork using default blob and base fee parameters instead of the forked chain's when the configured `chainId` differs from the remote chain's.
5 changes: 5 additions & 0 deletions .changeset/edr-fuzz-assume-rejects-not-runs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @popescuoctavian! Changed Solidity fuzz inputs rejected by `vm.assume` to no longer count towards `runs`.
5 changes: 5 additions & 0 deletions .changeset/edr-fuzz-failing-run-logs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @popescuoctavian! Changed Solidity fuzz tests to report the logs of the failing run even without `showLogs`.
5 changes: 5 additions & 0 deletions .changeset/edr-fuzz-failure-persist-file-removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": minor
---

Thanks @popescuoctavian! BREAKING CHANGE: Removed the `failurePersistFile` Solidity fuzz option, and setting it is now a config error. When `failurePersistDir` is set, failures are persisted under `failures`.
5 changes: 5 additions & 0 deletions .changeset/edr-fuzz-failure-persistence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @popescuoctavian! Changed Solidity fuzz failures to persist as one JSON counterexample per test, which is replayed first on the next run.
5 changes: 5 additions & 0 deletions .changeset/edr-fuzz-max-test-rejects-zero.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": minor
---

Thanks @popescuoctavian! BREAKING CHANGE: `maxTestRejects: 0` now disables the `vm.assume` reject limit in Solidity fuzz tests, instead of failing on the first rejected input, and requires a fuzz `timeout`.
6 changes: 6 additions & 0 deletions .changeset/edr-fuzz-parallel-workers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
# docs: https://github.com/NomicFoundation/hardhat-website/pull/335
"hardhat": minor
---

Thanks @popescuoctavian! Support parallel workers for Solidity fuzz tests.
5 changes: 5 additions & 0 deletions .changeset/edr-fuzz-vm-random-seed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @popescuoctavian! Fixed the `vm.random*` cheatcodes repeating the same sequence in every fuzz run under a fixed `seed`.
5 changes: 5 additions & 0 deletions .changeset/edr-solidity-0.8.38-coverage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hardhat": patch
---

Thanks @nebasuke! Added coverage support for Solidity 0.8.36, 0.8.37 and 0.8.38.
2 changes: 1 addition & 1 deletion packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"typescript": "~6.0.3"
},
"dependencies": {
"@nomicfoundation/edr": "0.25.1",
"@nomicfoundation/edr": "0.26.0",
"@nomicfoundation/hardhat-errors": "workspace:^3.1.3",
"@nomicfoundation/hardhat-utils": "workspace:^5.1.1",
"@nomicfoundation/hardhat-vendored": "workspace:^3.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ const solidityTestProfileUserConfigType = z.object({
fuzz: z
.object({
failurePersistDir: z.string().optional(),
failurePersistFile: z.string().optional(),
failurePersistFile: incompatibleFieldType(
"This field was removed, as failures are now persisted as one file per test in `failurePersistDir`",
),
runs: z.number().optional(),
maxTestRejects: z.number().optional(),
seed: z.string().optional(),
Expand All @@ -89,6 +91,7 @@ const solidityTestProfileUserConfigType = z.object({
includePushBytes: z.boolean().optional(),
showLogs: z.boolean().optional(),
timeout: nonnegativeSafeIntOrSafeBigInt.optional(),
workers: z.number().int().positive().safe().optional(),
Comment thread
kanej marked this conversation as resolved.
Resolved
})
.optional(),
forking: z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ declare module "../../../types/test.js" {

export interface SolidityTestFuzzUserConfig {
failurePersistDir?: string;
failurePersistFile?: string;
runs?: number;
maxTestRejects?: number;
seed?: string;
Expand All @@ -47,6 +46,7 @@ declare module "../../../types/test.js" {
includePushBytes?: boolean;
showLogs?: boolean;
timeout?: number | bigint;
workers?: number;
}

export interface SolidityTestForkingUserConfig {
Expand Down Expand Up @@ -115,7 +115,6 @@ declare module "../../../types/test.js" {

export interface SolidityTestFuzzConfig {
failurePersistDir?: string;
failurePersistFile?: string;
runs?: number;
maxTestRejects?: number;
seed: string;
Expand All @@ -124,6 +123,7 @@ declare module "../../../types/test.js" {
includePushBytes?: boolean;
showLogs?: boolean;
timeout?: number;
workers?: number;
}

export interface SolidityTestForkingConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ describe("config resolution", () => {
assert.equal(result.timeout, 30);
assert.equal(result.seed, DEFAULT_FUZZ_SEED);
});

it("should pass `workers` through when it is set", () => {
const result = resolveFuzzConfig({ workers: 1 });

assert.deepEqual(result, { seed: DEFAULT_FUZZ_SEED, workers: 1 });
});

it("should leave `workers` out when it isn't set, so EDR's default applies", () => {
const result = resolveFuzzConfig({ runs: 500 });

assert.ok(result !== undefined, "result is undefined");
assert.equal("workers" in result, false);
});
});

describe("resolveInvariantConfig", () => {
Expand Down Expand Up @@ -182,5 +195,23 @@ describe("config resolution", () => {
assert.equal(ci.forking?.blockNumber, 123n);
assert.equal(await ci.forking?.url?.get(), "https://example.com/ci");
});

it("should resolve `workers` per profile", async () => {
const hre = await createHardhatRuntimeEnvironment({
test: {
solidity: {
profiles: {
default: { fuzz: { runs: 500 } },
ci: { fuzz: { workers: 1 } },
},
},
},
});

const { default: defaultProfile, ci } = hre.config.test.solidity.profiles;

assert.equal(defaultProfile.fuzz.workers, undefined);
assert.equal(ci.fuzz.workers, 1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,89 @@ describe("config validation", () => {
);
});

it("should accept a positive integer `fuzz.workers`", async () => {
const hre = await createHardhatRuntimeEnvironment({
test: {
solidity: {
fuzz: { workers: 1 },
},
},
});

assert.equal(hre.config.test.solidity.profiles.default.fuzz.workers, 1);
});

it("should reject a `fuzz.workers` that isn't a positive integer", async () => {
for (const [workers, message] of [
[0, "Number must be greater than 0"],
[-1, "Number must be greater than 0"],
[1.5, "Expected integer, received float"],
] as const) {
const userConfig: HardhatUserConfig = {
test: {
solidity: {
fuzz: { workers },
},
},
};

await assertRejectsWithHardhatError(
createHardhatRuntimeEnvironment(userConfig),
HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG,
{
errors: `\t* Config error in config.test.solidity.fuzz.workers: ${message}`,
},
);
}
});

it("should reject the removed `fuzz.failurePersistFile` field", async () => {
const userConfig: HardhatUserConfig = {
test: {
solidity: {
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
-- intentionally violating the types for the test */
fuzz: { failurePersistFile: "failures" } as any,
},
},
};

await assertRejectsWithHardhatError(
createHardhatRuntimeEnvironment(userConfig),
HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG,
{
errors:
"\t* Config error in config.test.solidity.fuzz.failurePersistFile: This field was removed, as failures are now persisted as one file per test in `failurePersistDir`",
},
);
});

it("should reject the removed `fuzz.failurePersistFile` field in a profile", async () => {
const userConfig: HardhatUserConfig = {
test: {
solidity: {
profiles: {
default: {},
ci: {
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions
-- intentionally violating the types for the test */
fuzz: { failurePersistFile: "failures" } as any,
},
},
},
},
};

await assertRejectsWithHardhatError(
createHardhatRuntimeEnvironment(userConfig),
HardhatError.ERRORS.CORE.GENERAL.INVALID_CONFIG,
{
errors:
"\t* Config error in config.test.solidity.profiles.ci.fuzz.failurePersistFile: This field was removed, as failures are now persisted as one file per test in `failurePersistDir`",
},
);
});

it("should reject bigint invariant timeouts that cannot be represented as safe numbers", async () => {
const userConfig: HardhatUserConfig = {
test: {
Expand Down
66 changes: 33 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading