Skip to content

Commit f068c99

Browse files
Saty248alcuadrado
authored andcommitted
adding a function and editing the error message for the issue #4151
1 parent 0994eed commit f068c99

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

packages/hardhat-network-helpers/src/errors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class FixtureSnapshotError extends CustomError {
1717
super(
1818
`There was an error reverting the snapshot of the fixture.
1919
20-
This might be caused by using nested loadFixture calls in a test, for example by using multiple beforeEach calls. This is not supported yet.`,
20+
This might be caused by using hardhat_reset and loadFixture calls in a testcase.`,
2121
parent
2222
);
2323
}

packages/hardhat-network-helpers/src/helpers/reset.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { deleteOnReset } from "../loadFixture";
12
import type { NumberLike } from "../types";
23
import { getHardhatProvider, toNumber } from "../utils";
34

@@ -6,7 +7,7 @@ export async function reset(
67
blockNumber?: NumberLike
78
): Promise<void> {
89
const provider = await getHardhatProvider();
9-
10+
deleteOnReset();
1011
if (url === undefined) {
1112
await provider.request({
1213
method: "hardhat_reset",

packages/hardhat-network-helpers/src/loadFixture.ts

+5
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,8 @@ export async function loadFixture<T>(fixture: Fixture<T>): Promise<T> {
6868
return data;
6969
}
7070
}
71+
72+
// function to clear the snapshots array when hardhat_reset is called..
73+
export async function deleteOnReset(){
74+
snapshots=[];
75+
}

0 commit comments

Comments
 (0)