sanity.test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. const { ethers } = require('hardhat');
  2. const { expect } = require('chai');
  3. const { loadFixture, mine } = require('@nomicfoundation/hardhat-network-helpers');
  4. async function fixture() {
  5. const signers = await ethers.getSigners();
  6. const addresses = await Promise.all(signers.map(s => s.getAddress()));
  7. return { signers, addresses };
  8. }
  9. describe('Environment sanity', function () {
  10. beforeEach(async function () {
  11. Object.assign(this, await loadFixture(fixture));
  12. });
  13. describe('[skip-on-coverage] signers', function () {
  14. it('signer #0 is skipped', async function () {
  15. const signer = await ethers.provider.getSigner(0);
  16. expect(this.addresses).to.not.include(await signer.getAddress());
  17. });
  18. });
  19. describe('snapshot', function () {
  20. let blockNumberBefore;
  21. it('cache and mine', async function () {
  22. blockNumberBefore = await ethers.provider.getBlockNumber();
  23. await mine();
  24. expect(await ethers.provider.getBlockNumber()).to.be.equal(blockNumberBefore + 1);
  25. });
  26. it('check snapshot', async function () {
  27. expect(await ethers.provider.getBlockNumber()).to.be.equal(blockNumberBefore);
  28. });
  29. });
  30. });