Skip to content

Commit 1a87de9

Browse files
arr00Amxx
andauthored
Use hardhat network helper to clear code blockhash test (#5768)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
1 parent 2422d7c commit 1a87de9

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@eslint/compat": "^1.2.1",
6060
"@nomicfoundation/hardhat-chai-matchers": "^2.0.6",
6161
"@nomicfoundation/hardhat-ethers": "^3.0.9",
62-
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
62+
"@nomicfoundation/hardhat-network-helpers": "^1.0.13",
6363
"@openzeppelin/docs-utils": "^0.1.5",
6464
"@openzeppelin/merkle-tree": "^1.0.7",
6565
"@openzeppelin/upgrade-safe-transpiler": "^0.3.32",

test/utils/Blockhash.test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
const { ethers, network } = require('hardhat');
1+
const { ethers, eip2935 } = require('hardhat');
22
const { expect } = require('chai');
3-
const { loadFixture, mineUpTo } = require('@nomicfoundation/hardhat-network-helpers');
3+
const { loadFixture, mineUpTo, setCode } = require('@nomicfoundation/hardhat-network-helpers');
44
const { impersonate } = require('../helpers/account');
55

6-
const HISTORY_STORAGE_ADDRESS = '0x0000F90827F1C53a10cb7A02335B175320002935';
76
const SYSTEM_ADDRESS = '0xfffffffffffffffffffffffffffffffffffffffe';
87
const HISTORY_SERVE_WINDOW = 8191;
98
const BLOCKHASH_SERVE_WINDOW = 256;
@@ -25,10 +24,9 @@ describe('Blockhash', function () {
2524
describe(`${supported ? 'supported' : 'unsupported'} chain`, function () {
2625
beforeEach(async function () {
2726
if (supported) {
28-
await this.systemSigner.sendTransaction({ to: HISTORY_STORAGE_ADDRESS, data: this.latestBlock.hash });
27+
await this.systemSigner.sendTransaction({ to: eip2935, data: this.latestBlock.hash });
2928
} else {
30-
// `setCode` in hardhat-network-helpers doesn't support empty code :/
31-
await network.provider.request({ method: 'hardhat_setCode', params: [HISTORY_STORAGE_ADDRESS, '0x'] });
29+
await setCode(eip2935.target, '0x');
3230
}
3331
});
3432

0 commit comments

Comments
 (0)