env-contract.js 733 B

12345678910111213141516171819202122232425
  1. extendEnvironment(env => {
  2. const { contract } = env;
  3. env.contract = function (name, body) {
  4. const { takeSnapshot } = require('@nomicfoundation/hardhat-network-helpers');
  5. contract(name, accounts => {
  6. // reset the state of the chain in between contract test suites
  7. let snapshot;
  8. before(async function () {
  9. snapshot = await takeSnapshot();
  10. });
  11. after(async function () {
  12. await snapshot.restore();
  13. });
  14. // remove the default account from the accounts list used in tests, in order
  15. // to protect tests against accidentally passing due to the contract
  16. // deployer being used subsequently as function caller
  17. body(accounts.slice(1));
  18. });
  19. };
  20. });