File tree 3 files changed +15
-6
lines changed
packages/hardhat-network-helpers
3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
- import { deleteOnReset } from "../loadFixture" ;
2
1
import type { NumberLike } from "../types" ;
2
+ import { clearSnapshots } from "../loadFixture" ;
3
+
3
4
import { getHardhatProvider , toNumber } from "../utils" ;
4
5
5
6
export async function reset (
6
7
url ?: string ,
7
8
blockNumber ?: NumberLike
8
9
) : Promise < void > {
9
10
const provider = await getHardhatProvider ( ) ;
10
- deleteOnReset ( ) ;
11
+ clearSnapshots ( ) ;
11
12
if ( url === undefined ) {
12
13
await provider . request ( {
13
14
method : "hardhat_reset" ,
Original file line number Diff line number Diff line change @@ -70,6 +70,6 @@ export async function loadFixture<T>(fixture: Fixture<T>): Promise<T> {
70
70
}
71
71
72
72
// function to clear the snapshots array when hardhat_reset is called..
73
- export async function deleteOnReset ( ) {
74
- snapshots = [ ] ;
73
+ export async function clearSnapshots ( ) {
74
+ snapshots = [ ] ;
75
75
}
Original file line number Diff line number Diff line change 1
1
import { assert } from "chai" ;
2
-
3
2
import * as hh from "../../src" ;
4
3
import { INFURA_URL } from "../setup" ;
5
4
import { useEnvironment } from "../test-utils" ;
6
-
7
5
describe ( "resetWithoutFork" , function ( ) {
8
6
useEnvironment ( "simple" ) ;
9
7
@@ -56,3 +54,13 @@ describe("resetWithoutFork", function () {
56
54
assert . equal ( olderMainnetBlockNumber , mainnetBlockNumber - 1000 ) ;
57
55
} ) ;
58
56
} ) ;
57
+
58
+ describe ( "should clear snapshot upon reset" , async function ( ) {
59
+ useEnvironment ( "simple" ) ;
60
+ it ( "checks if the snapshot is cleared upon hardhat_reset" , async function ( ) {
61
+ const snapshotBeforeReset = await hh . takeSnapshot ( ) ;
62
+ await hh . reset ( ) ;
63
+ const snapshotAfterReset = await hh . takeSnapshot ( ) ;
64
+ assert . equal ( snapshotBeforeReset . snapshotId , snapshotAfterReset . snapshotId ) ;
65
+ } ) ;
66
+ } ) ;
You can’t perform that action at this time.
0 commit comments