Browse Source

Fix flaky test in AccessManager (#4593)

Francisco 2 years ago
parent
commit
9e09e0653a
1 changed files with 3 additions and 4 deletions
  1. 3 4
      test/access/manager/AccessManager.test.js

+ 3 - 4
test/access/manager/AccessManager.test.js

@@ -4,6 +4,7 @@ const { expectRevertCustomError } = require('../../helpers/customError');
 const { selector } = require('../../helpers/methods');
 const { selector } = require('../../helpers/methods');
 const { clockFromReceipt } = require('../../helpers/time');
 const { clockFromReceipt } = require('../../helpers/time');
 const { product } = require('../../helpers/iterate');
 const { product } = require('../../helpers/iterate');
+const helpers = require('@nomicfoundation/hardhat-network-helpers');
 
 
 const AccessManager = artifacts.require('$AccessManager');
 const AccessManager = artifacts.require('$AccessManager');
 const AccessManagedTarget = artifacts.require('$AccessManagedTarget');
 const AccessManagedTarget = artifacts.require('$AccessManagedTarget');
@@ -883,17 +884,15 @@ contract('AccessManager', function (accounts) {
 
 
         expect(await this.manager.getSchedule(this.opId)).to.be.bignumber.equal(timestamp.add(executeDelay));
         expect(await this.manager.getSchedule(this.opId)).to.be.bignumber.equal(timestamp.add(executeDelay));
 
 
-        // we need to set the clock 2 seconds before the value, because the increaseTo "consumes" the timestamp
-        // and the next transaction will be one after that (see check below)
-        await time.increaseTo(timestamp.add(executeDelay).subn(2));
-
         // too early
         // too early
+        await helpers.time.setNextBlockTimestamp(timestamp.add(executeDelay).subn(1));
         await expectRevertCustomError(this.execute(), 'AccessManagerNotReady', [this.opId]);
         await expectRevertCustomError(this.execute(), 'AccessManagerNotReady', [this.opId]);
 
 
         // the revert happened one second before the execution delay expired
         // the revert happened one second before the execution delay expired
         expect(await time.latest()).to.be.bignumber.equal(timestamp.add(executeDelay).subn(1));
         expect(await time.latest()).to.be.bignumber.equal(timestamp.add(executeDelay).subn(1));
 
 
         // ok
         // ok
+        await helpers.time.setNextBlockTimestamp(timestamp.add(executeDelay));
         await this.execute();
         await this.execute();
 
 
         // the success happened when the delay was reached (earliest possible)
         // the success happened when the delay was reached (earliest possible)