Use hardhat network helper to clear code blockhash test (#5768)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Arr00
2025-06-26 10:50:39 -04:00
committed by GitHub
parent 2422d7cf7f
commit 1a87de9326
3 changed files with 9 additions and 11 deletions

8
package-lock.json generated
View File

@ -16,7 +16,7 @@
"@eslint/compat": "^1.2.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.6",
"@nomicfoundation/hardhat-ethers": "^3.0.9",
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
"@nomicfoundation/hardhat-network-helpers": "^1.0.13",
"@openzeppelin/docs-utils": "^0.1.5",
"@openzeppelin/merkle-tree": "^1.0.7",
"@openzeppelin/upgrade-safe-transpiler": "^0.3.32",
@ -1846,9 +1846,9 @@
}
},
"node_modules/@nomicfoundation/hardhat-network-helpers": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/@nomicfoundation/hardhat-network-helpers/-/hardhat-network-helpers-1.0.12.tgz",
"integrity": "sha512-xTNQNI/9xkHvjmCJnJOTyqDSl8uq1rKb2WOVmixQxFtRd7Oa3ecO8zM0cyC2YmOK+jHB9WPZ+F/ijkHg1CoORA==",
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/@nomicfoundation/hardhat-network-helpers/-/hardhat-network-helpers-1.0.13.tgz",
"integrity": "sha512-ptg0+SH8jnfoYHlR3dKWTNTB43HZSxkuy3OeDk+AufEKQvQ7Ru9LQEbJtLuDTQ4HGRBkhl4oJ9RABsEIbn7Taw==",
"dev": true,
"license": "MIT",
"dependencies": {

View File

@ -59,7 +59,7 @@
"@eslint/compat": "^1.2.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.6",
"@nomicfoundation/hardhat-ethers": "^3.0.9",
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
"@nomicfoundation/hardhat-network-helpers": "^1.0.13",
"@openzeppelin/docs-utils": "^0.1.5",
"@openzeppelin/merkle-tree": "^1.0.7",
"@openzeppelin/upgrade-safe-transpiler": "^0.3.32",

View File

@ -1,9 +1,8 @@
const { ethers, network } = require('hardhat');
const { ethers, eip2935 } = require('hardhat');
const { expect } = require('chai');
const { loadFixture, mineUpTo } = require('@nomicfoundation/hardhat-network-helpers');
const { loadFixture, mineUpTo, setCode } = require('@nomicfoundation/hardhat-network-helpers');
const { impersonate } = require('../helpers/account');
const HISTORY_STORAGE_ADDRESS = '0x0000F90827F1C53a10cb7A02335B175320002935';
const SYSTEM_ADDRESS = '0xfffffffffffffffffffffffffffffffffffffffe';
const HISTORY_SERVE_WINDOW = 8191;
const BLOCKHASH_SERVE_WINDOW = 256;
@ -25,10 +24,9 @@ describe('Blockhash', function () {
describe(`${supported ? 'supported' : 'unsupported'} chain`, function () {
beforeEach(async function () {
if (supported) {
await this.systemSigner.sendTransaction({ to: HISTORY_STORAGE_ADDRESS, data: this.latestBlock.hash });
await this.systemSigner.sendTransaction({ to: eip2935, data: this.latestBlock.hash });
} else {
// `setCode` in hardhat-network-helpers doesn't support empty code :/
await network.provider.request({ method: 'hardhat_setCode', params: [HISTORY_STORAGE_ADDRESS, '0x'] });
await setCode(eip2935.target, '0x');
}
});