Migrate AccessControl tests (#4694)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Ernesto García
2023-10-25 20:52:09 -06:00
committed by GitHub
parent 7c8b7a2728
commit 2ec2ed9695
6 changed files with 491 additions and 491 deletions

View File

@ -1,5 +1,7 @@
const { time, mineUpTo } = require('@nomicfoundation/hardhat-network-helpers');
const mapObject = (obj, fn) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, fn(value)]));
module.exports = {
clock: {
blocknumber: () => time.latestBlock(),
@ -13,6 +15,15 @@ module.exports = {
},
forward: {
blocknumber: mineUpTo,
timestamp: time.increaseTo,
timestamp: (to, mine = true) => (mine ? time.increaseTo(to) : time.setNextBlockTimestamp(to)),
},
duration: time.duration,
};
// TODO: deprecate the old version in favor of this one
module.exports.bigint = {
clock: mapObject(module.exports.clock, fn => () => fn().then(BigInt)),
clockFromReceipt: mapObject(module.exports.clockFromReceipt, fn => receipt => fn(receipt).then(BigInt)),
forward: module.exports.forward,
duration: mapObject(module.exports.duration, fn => n => BigInt(fn(n))),
};