Migrate governance tests to ethers.js (#4728)

Co-authored-by: ernestognw <ernestognw@gmail.com>
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
Renan Souza
2023-12-18 17:09:23 -03:00
committed by GitHub
parent d155600d55
commit c3cd70811b
22 changed files with 3663 additions and 3861 deletions

View File

@ -1,3 +1,4 @@
const { ethers } = require('hardhat');
const { time, mineUpTo } = require('@nomicfoundation/hardhat-network-helpers');
const { mapValues } = require('./iterate');
@ -8,9 +9,7 @@ module.exports = {
},
clockFromReceipt: {
blocknumber: receipt => Promise.resolve(receipt.blockNumber),
timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp),
// TODO: update for ethers receipt
// timestamp: receipt => receipt.getBlock().then(block => block.timestamp),
timestamp: receipt => ethers.provider.getBlock(receipt.blockNumber).then(block => block.timestamp),
},
forward: {
blocknumber: mineUpTo,
@ -21,8 +20,8 @@ module.exports = {
// TODO: deprecate the old version in favor of this one
module.exports.bigint = {
clock: mapValues(module.exports.clock, fn => () => fn().then(BigInt)),
clockFromReceipt: mapValues(module.exports.clockFromReceipt, fn => receipt => fn(receipt).then(BigInt)),
clock: mapValues(module.exports.clock, fn => () => fn().then(ethers.toBigInt)),
clockFromReceipt: mapValues(module.exports.clockFromReceipt, fn => receipt => fn(receipt).then(ethers.toBigInt)),
forward: module.exports.forward,
duration: mapValues(module.exports.duration, fn => n => BigInt(fn(n))),
duration: mapValues(module.exports.duration, fn => n => ethers.toBigInt(fn(ethers.toNumber(n)))),
};