Refactor time helper and remove custom error helper. (#4803)
Co-authored-by: ernestognw <ernestognw@gmail.com>
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
const { ethers } = require('hardhat');
|
||||
const { setStorageAt } = require('@nomicfoundation/hardhat-network-helpers');
|
||||
|
||||
const { EXECUTION_ID_STORAGE_SLOT, EXPIRATION, prepareOperation } = require('../../helpers/access-manager');
|
||||
const { impersonate } = require('../../helpers/account');
|
||||
const { bigint: time } = require('../../helpers/time');
|
||||
const { ethers } = require('hardhat');
|
||||
|
||||
// ============ COMMON PREDICATES ============
|
||||
|
||||
@ -146,7 +147,7 @@ function testAsDelay(type, { before, after }) {
|
||||
|
||||
describe(`when ${type} delay has not taken effect yet`, function () {
|
||||
beforeEach(`set next block timestamp before ${type} takes effect`, async function () {
|
||||
await time.forward.timestamp(this.delayEffect - 1n, !!before.mineDelay);
|
||||
await time.increaseTo.timestamp(this.delayEffect - 1n, !!before.mineDelay);
|
||||
});
|
||||
|
||||
before();
|
||||
@ -154,7 +155,7 @@ function testAsDelay(type, { before, after }) {
|
||||
|
||||
describe(`when ${type} delay has taken effect`, function () {
|
||||
beforeEach(`set next block timestamp when ${type} takes effect`, async function () {
|
||||
await time.forward.timestamp(this.delayEffect, !!after.mineDelay);
|
||||
await time.increaseTo.timestamp(this.delayEffect, !!after.mineDelay);
|
||||
});
|
||||
|
||||
after();
|
||||
@ -187,7 +188,7 @@ function testAsSchedulableOperation({ scheduled: { before, after, expired }, not
|
||||
beforeEach('set next block time before operation is ready', async function () {
|
||||
this.scheduledAt = await time.clock.timestamp();
|
||||
const schedule = await this.manager.getSchedule(this.operationId);
|
||||
await time.forward.timestamp(schedule - 1n, !!before.mineDelay);
|
||||
await time.increaseTo.timestamp(schedule - 1n, !!before.mineDelay);
|
||||
});
|
||||
|
||||
before();
|
||||
@ -197,7 +198,7 @@ function testAsSchedulableOperation({ scheduled: { before, after, expired }, not
|
||||
beforeEach('set next block time when operation is ready for execution', async function () {
|
||||
this.scheduledAt = await time.clock.timestamp();
|
||||
const schedule = await this.manager.getSchedule(this.operationId);
|
||||
await time.forward.timestamp(schedule, !!after.mineDelay);
|
||||
await time.increaseTo.timestamp(schedule, !!after.mineDelay);
|
||||
});
|
||||
|
||||
after();
|
||||
@ -207,7 +208,7 @@ function testAsSchedulableOperation({ scheduled: { before, after, expired }, not
|
||||
beforeEach('set next block time when operation expired', async function () {
|
||||
this.scheduledAt = await time.clock.timestamp();
|
||||
const schedule = await this.manager.getSchedule(this.operationId);
|
||||
await time.forward.timestamp(schedule + EXPIRATION, !!expired.mineDelay);
|
||||
await time.increaseTo.timestamp(schedule + EXPIRATION, !!expired.mineDelay);
|
||||
});
|
||||
|
||||
expired();
|
||||
|
||||
Reference in New Issue
Block a user